How to extract the ENTRYPOINT and COMMAND of a Docker container image

You can use docker inspect like this to extract the ENTRYPOINT of a docker image.

docker_inspect_entrypoint.sh
docker inspect IMAGE --format='{{.Config.Entrypoint}}'

What’s often also useful is to print it in conjunction with the command:

docker_inspect_entrypoint_cmd.sh
docker inspect IMAGE --format='ENTRYPOINT: {{.Config.Entrypoint}} CMD: {{.Config.Cmd}}'

Example:

docker_inspect_example_output_1.txt
$ docker inspect nginxinc/nginx-s3-gateway:latest --format='{{.Config.Entrypoint}}'
[/docker-entrypoint.sh]
docker_inspect_example_output_2.txt
$ docker inspect nginxinc/nginx-s3-gateway:latest --format='ENTRYPOINT: {{.Config.Entrypoint}} CMD: {{.Config.Cmd}}'
ENTRYPOINT: [/docker-entrypoint.sh] CMD: [nginx -g daemon off;]

Check out similar posts by category: Docker