Docker What is the difference between CMD and ENTRYPOINT in a Dockerfile

preview_player
Показать описание
What is the difference between CMD and ENTRYPOINT in a Dockerfile
a)
without entrypoint:
sudo docker run --rm myimage1 /bin/ls dev
sudo docker run --rm myimage1 /bin/ls var
b)
with entrypoint:
sudo docker run --rm --entrypoint="/bin/ls" myimage1 dev
sudo docker run --rm --entrypoint="/bin/ls" myimage1 var
c)
with entrypoint in Dockerfile:
# Dockerfile
FROM centos:7.4.1708
ENTRYPOINT ["/bin/ls"]

sudo docker build -t myimage2 .
sudo docker run --rm myimage2
sudo docker run --rm myimage2 dev
sudo docker run --rm myimage2 /bin/ls dev
d)
with entrypoint in Dockerfile:
# Dockerfile
FROM centos:7.4.1708
CMD var
ENTRYPOINT ["/bin/ls"]

sudo docker build -t myimage3 .
sudo docker run --rm myimage3
sudo docker run --rm myimage3 dev
sudo docker run --rm myimage3 /bin/ls dev
Рекомендации по теме