In Dockerfiles there are two commands that look similar to me: CMD
and ENTRYPOINT
. But I guess that there is a (subtle?) difference between them -
Most people explain it perfectly here, so I won't repeat all the answers. But to get a good feeling I would suggest testing it yourself by looking at the processes in the container.
Create a tiny Dockerfile of the form:
FROM ubuntu:latest
CMD /bin/bash
Build it, run it in with docker run -it theimage
and run ps -eo ppid,pid,args
in the container.
Compare this output to the output you receive from ps when using:
docker run -it theimage bash
ENTRYPOINT /bin/bash
and running it in both waysCMD ["/bin/bash"]
This way you will easily see the differences between all possible methods for yourself.