ScanSkill

docker inspect

The command docker inspect return detailed low-level information on constructs controlled by Docker. It renders results in a JSON array.

Syntax

$ docker inspect [OPTIONS] NAME|ID [NAME|ID...]

Here,

Options:

  • --size, -s → Total file sizes if the type is the container
  • --format, or -f → Pretty-print images using a Go template
  • --type → JSON for the specified type

Examples

  • Get the IP address of an instance
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID
  • Get the MAC address of an instance
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID
  • Get the log path of an instance
$ docker inspect --format='{{.LogPath}}' $INSTANCE_ID
  • Get the image name of an instance
$ docker inspect --format='{{.Config.Image}}' $INSTANCE_ID
  • Find specific port mapping(eg. 8080)
$ docker inspect --format='{{(index (index .NetworkSettings.Ports "8080/tcp") 0).HostPort}}' $INSTANCE_ID