文档中说,command是覆盖容器启动后默认执行的命令。http://wiki.jikexueyuan.com/project/docker-technology-and-combat/yaml_file.html
command: bundle exec thin -p 3000
那么,容器默认执行命令在哪里查看?
能否以Docker Hub官方nginx镜像为例说一下:
https://hub.docker.com/r/library/nginx/
PHPz2017-04-24 09:13:58
docker run nginx && docker ps --no-trunc
The command column is the command that is executed by default
If there is a Dockerfile, usually the last line CMD
或 ENTRYPOINT
is it
CMD commands can be overwritten by docker run
following commands, but ENTRYPOINT will not
Regardless of CMD or ENTRYPOINT, when there are multiple entries in the same Dockerfile, only the last one will be executed
e.g :
nginx:stable-alpine Dockerfile
For example, this (docker run --rm nginx:stable-alpine /bin/sh) you will find that nginx is not running
The command in docker-compose.yml is the one specified after docker run /bin/sh