Docker inspect list ports, volumes and etc. Docker inspect list ports, volumes and etc. – My IT experience

Docker inspect list ports, volumes and etc.

The `docker inspect` returns useful information about Docker containers.

To filter the returned input one can request a return format.

Main documentation can be found here:
https://docs.docker.com/engine/reference/commandline/inspect/

A peace of information that is not immediately visible, but is always of interest is the list of volumes bonded, which can be extracted as follows:

docker inspect --format='{{json .HostConfig.Binds}}' container_name

To retrieve a list of the binds separated by a new line:

docker inspect --format='{{json .HostConfig.Binds}}' container_name | \
sed 's/"//g;s/\[//g;s/\]//g'| \
tr ',' '\n' 

For the network settings:

docker inspect --format='{{json .NetworkSettings.Ports}}' container_name

To find the command which was used when the docker was started:

docker inspect  -f "{{.Name}} {{.Config.Cmd}}" container_name

To find the environment variables with which the container was started:

docker inspect --format "{{.Config.Env}}" container_name

Many more useful inspect format magics could be found here:

Docker Inspect Template Magic

Categories