Docker cmd and entrypoint explanation

As per the below image there is only one CMD and ENTRYPOINT instruction. According to the documents (as I understood) ENTRYPOINT will get the values in CMD as arguments. However, when I run this image I don’t see the value “python3” passed in as an argument to “certbot”. Can someone explain this behavior please.

https://hub.docker.com/layers/certbot/certbot/latest/images/sha256-835f40053d6621fa90acf4bccf84c4683f27ff5eae6b59dbe7ea6474093ce2c6?context=explore

The certbot/certbot image is built on top of the python image, which has the CMD ["python3"] you see

Specifying a new ENTRYPOINT resets the CMD inherited

1 Like

@deanayalon is absolutely right.

You can inspect an image and use gotemplate format strings to render the command used to start the process inside the container:

docker image inspect \
  --format '{{range  .Config.Entrypoint}}{{.}} {{end}}{{range .Config.Cmd}}{{.}} {{end}}' \
  certbot/certbot:latest

If you want to identify the entrypoint and cmd parts individually:

 docker image inspect \
  --format 'Entrypoint: {{range  .Config.Entrypoint}}{{.}} {{end}}{{print "\n" }}CMD: {{range .Config.Cmd}}{{.}} {{end}}' \
 certbot/certbot:latest

You can use the command with every image, you just need to make sure to pull the image before and replace the repo:tag with the image you want to inspect.

1 Like