dockerdockerfiledocker-cmd

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/engine/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

Solution

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

     docker run --name test test/test-backend /srv/www/bin/gunicorn.sh