What is the difference between CMD and ENTRYPOINT in a Dockerfile?
Asked 07 September, 2021
Viewed 2.4K times
  • 55
Votes

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 - otherwise it would not make any sense to have two commands for the very same thing.

The documentation states for CMD


  

The main purpose of a CMD is to provide defaults for an executing container.

and for ENTRYPOINT:


  

An ENTRYPOINT helps you to configure a container that you can run as an executable.

So, what's the difference between those two commands?

17 Answer