例如,我用docker hub
的Debian官方镜像创建了一个容器,然后进入容器update了一番,然后又部署了一个nginx服务,并在rc.local里设置自启,之后退出容器并将该容器commit
了一个新镜像A。之后我尝试从A镜像启动一个容器却发现启动失败了,docker run -d
后docker ps
里没有该容器,docker run -it
后退出容器后容器随之也关闭了。请问这是什么原因呢?求解答谢谢。
Dockerfile用得还不是很应手。
伊谢尔伦2017-04-26 09:03:33
A container needs a service to run in order to run, and it is officially recommended that a container only run one service
All Dockerfiles are followed by CMD or ENTRYPOINT. If you want to run your image in the background, just follow run -d with a persistent command or program
黄舟2017-04-26 09:03:33
Yes! But your nginx service runs in the foreground of the container. Do not add it to the system’s services