Custom Search

Saturday, November 17, 2018

What is the difference between CMD and ENTRYPOINT in a Dockerfile

a)
without entrypoint:
sudo docker run --rm myimage /bin/ls dev
sudo docker run --rm myimage /bin/ls var

b)
with entrypoint:
sudo docker run --rm --entrypoint="/bin/ls" myimage dev
sudo docker run --rm --entrypoint="/bin/ls" myimage var

c)
with entrypoint in Dockerfile:
# Dockerfile
FROM centos:7.4.1708
ENTRYPOINT ["/bin/ls"]

sudo docker build -t myimage1 .


sudo docker run --rm myimage1 dev
sudo docker run --rm myimage1 /bin/ls dev

d)
with entrypoint in Dockerfile:
# Dockerfile
FROM centos:7.4.1708
CMD dev
ENTRYPOINT ["/bin/ls"]

sudo docker build -t myimage1 .

sudo docker run --rm myimage1

No comments:

Post a Comment