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 -
CMD:
CMD ["executable","param1","param2"]
: ["executable","param1","param2"]
is the first process.CMD command param1 param2
: /bin/sh -c CMD command param1 param2
is the first process. CMD command param1 param2
is forked from the first process.CMD ["param1","param2"]
: This form is used to provide default arguments for ENTRYPOINT
.ENTRYPOINT (The following list does not consider the case where CMD and ENTRYPOINT are used together):
ENTRYPOINT ["executable", "param1", "param2"]
: ["executable", "param1", "param2"]
is the first process.ENTRYPOINT command param1 param2
: /bin/sh -c command param1 param2
is the first process. command param1 param2
is forked from the first process.As creack said, CMD was developed first. Then ENTRYPOINT was developed for more customization. Since they are not designed together, there are some functionality overlaps between CMD and ENTRYPOINT, which often confuse people.