Home  >  Q&A  >  body text

docker-compose.yml文件中的command命令问题

文档中说,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/

阿神阿神2707 days ago681

reply all(1)I'll reply

  • PHPz

    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

    reply
    0
  • Cancelreply