简体   繁体   中英

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

As you know, in a Dockerfile, you can specify commands through the RUN and CMD parameters (example bellow).

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

In the docker-compose.yml , you can also specify the command parameter (example bellow).

...

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

What is the difference?

command parameter in docker-compose file is overriding the default CMD from the DockerFile .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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