繁体   English   中英

docker-compose.yml中的“command”参数和Dockerfile中的CMD参数有什么区别?

[英]What is the difference between the "command" parameter in the docker-compose.yml and the CMD parameter in the Dockerfile?

如您所知,在 Dockerfile 中,您可以通过 RUN 和 CMD 参数指定命令(示例如下)。

...
RUN pip3 install --upgrade pip
RUN pip3 install pytest
...
CMD ["python3", "main.py"]
...

docker-compose.yml中,您还可以指定命令参数(示例如下)。

...

services:
    conteiner_a:
        ...
        command: ["echo", "!!!!!!!! Container_A is available now !!!!!!!!"]
...

有什么区别?

docker-compose文件中的command参数覆盖来自DockerFile CMD

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM