Docker CMD vs ENTRYPOINT

April 7th, 2017 Posted by Blog, DevOps, Tips 0 thoughts on “Docker CMD vs ENTRYPOINT”

CMD arguments can be overridden:

Dockerfile:

FROM centos:7
CMD ["echo"]
docker build .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM ubuntu:16.04
---> bd3d4369aebc
Step 2 : ENTRYPOINT echo
---> Running in 7951a71e0c69
---> d8eedc1c5380
Removing intermediate container 7951a71e0c69
Successfully built d8eedc1c5380
docker run d8eedc1c5380 ls
bin
boot
dev
etc

ENTRYPOINT arguments can NOT be overridden:

Dockerfile:

FROM centos:7
ENTRYPOINT ["echo"]
docker build .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM ubuntu:16.04
---> bd3d4369aebc
Step 2 : ENTRYPOINT echo
---> Running in 96697aa9cfd9
---> e1397282b7cf
Removing intermediate container 96697aa9cfd9
Successfully built e1397282b7cf
docker run e1397282b7cf ls
ls

Continuous S.A.
Avenue des Hauts-Fourneaux 9
L-4362 Esch-sur-Alzette
Luxembourg

© Continuous S.A. 2017