首页 > 解决方案 > Dockerfile 入口点 - 仍然以 exec $@ 退出?

问题描述

我正在开发一个使用 megacmd 的容器(来自存储提供商 Mega.nz 的 CLI 同步实用程序)。

对 Dockerfiles 来说相对较新,我已经成功制作了一个 dockerfile,它将安装 MegaCMD 并登录,但一旦这样做,它就会停止容器。

在我的 compose 文件中,我设置tty: true了 ,认为这会使它保持活力,但事实并非如此。

FROM ubuntu:groovy

ENV email=email@example.com
ENV password=notyourpassword

RUN apt-get update \
....more stuff here

COPY megalogin.sh /usr/bin/local/megalogin.sh
ENTRYPOINT ["sh", "/usr/bin/local/megalogin.sh"]
####Works up to here but the container still stops when finished the login script

巨额登录.sh

#!/bin/sh
mega-login ${email} ${password}
mega-whoami

我需要做什么才能让这个东西继续运行?我已经exec "$@"在脚本末尾尝试过,但这没有任何区别。

标签: dockerfile

解决方案


当您运行容器时,将其附加tail -f /dev/nulldocker run命令中,例如

docker run -d [container-name] tail -f /dev/null

然后,您应该能够使用 exec 进入正在运行的容器docker exec [container-name] /bin/bash


推荐阅读