Alexander Rakhmaev
Alexander Rakhmaev

Reputation: 1055

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?

Upvotes: 0

Views: 219

Answers (1)

David
David

Reputation: 864

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

Upvotes: 1

Related Questions