dockerfile - 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 "$@"
在脚本末尾尝试过,但这没有任何区别。
解决方案
当您运行容器时,将其附加tail -f /dev/null
到docker run
命令中,例如
docker run -d [container-name] tail -f /dev/null
然后,您应该能够使用 exec 进入正在运行的容器docker exec [container-name] /bin/bash
推荐阅读
- python - 在更大的图片中定位图片
- python - Python 中 Google Search Console API 示例脚本的 JSONDecodeError
- java - REST API 中的线程“主”java.lang.IllegalArgumentException 中的异常
- java - Quarkus 扩展 (io.quarkus:quarkus-spring-data-jpa) 存储库无法返回字符串集合
- python - Jupyter 笔记本单元不打印任何内容
- excel - 等待 Context.sync 后如何将字符串转换为范围?
- c++ - 使用带有 LibZip 的 SDL_image 和 SDL_RWops 将 png 从 zip 加载到表面上,但无法识别 png
- python - 参数化值以在 Python 中过滤熊猫行
- python - 为什么使用 scikit-learn 管道时 self 不是类实例?
- javascript - 如何访问由参数传递的 JSON 密钥?