1👍
✅
ENTRYPOINT
and CMD
defines the default command that docker runs when it starts your container, not when the image is built. When ENTRYPOINT
isn’t defined, you simply run the value of CMD
. Otherwise, CMD
becomes args to the ENTRYPOINT
. When you run your image, you can override the value of the CMD
by passing args after the container name.
So, in your example above, CMD
may be defined as anything, but when you run your container with docker run -it <imagename> /bin/bash
, you override any value of CMD
and replace it with /bin/bash. To run the defined value of CMD
, you would need to run the container with docker run <imagename>
.
Source:stackexchange.com