Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override the CMD command in the docker run line

How you can replace the cmd based on the docker documentation: https://docs.docker.com/reference/builder/#cmd

You can override the CMD command

Dockerfile:

RUN chmod +x /srv/www/bin/* & chmod -R 755 /srv/www/app
RUN pip3 install -r /srv/www/app/pip-requirements.txt
EXPOSE 80
CMD ["/srv/www/bin/gunicorn.sh"]

the docker run command is:

docker run --name test test/test-backend

I tried

docker run --name test test --cmd ["/srv/www/bin/gunicorn.sh"]
docker run --name test test cmd ["/srv/www/bin/gunicorn.sh"]

But the console say this error:

System error: exec: "cmd": executable file not found in $PATH
like image 214
Hetdev Avatar asked Oct 06 '15 21:10

Hetdev


People also ask

Can we override CMD in Dockerfile?

Docker CMD The CMD instruction is only utilized if there is no argument added to the run command when starting a container. Therefore, if you add an argument to the command, you override the CMD.

How do I override command prompt?

To use a prompt override program, follow these steps: Specify any parameters that are to be key parameters on the PARM statement in the command definition source. Write a prompt override program. Specify the name of the prompt override program on the PMTOVRPGM parameter when you create or change the command.

What is CMD command in docker?

The CMD command​ specifies the instruction that is to be executed when a Docker container starts.

Can I override docker ENTRYPOINT?

The ENTRYPOINT or CMD that you specify in your Dockerfile identify the default executable for your image. However, the user has the option to override either of these values at run time.


1 Answers

The right way to do it is deleting cmd ["..."]

 docker run --name test test/test-backend /srv/www/bin/gunicorn.sh
like image 87
Hetdev Avatar answered Oct 16 '22 09:10

Hetdev