Difference between revisions of "Docker inspect"

From wikieduonline
Jump to navigation Jump to search
 
(47 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<code>docker inspect CONTAINER_ID|IMAGE_ID</code> (also available for: container, image, volume, network, node, service, or task)
+
{{lc}}
 +
<code>[[docker]] inspect [[CONTAINER]]_ID|[[IMAGE_ID]]</code> (also available for: container, image, volume, network, node, service, or task)
 
* http://manpages.ubuntu.com/manpages/disco/man1/docker-inspect.1.html  
 
* http://manpages.ubuntu.com/manpages/disco/man1/docker-inspect.1.html  
 
* https://docs.docker.com/engine/reference/commandline/inspect/
 
* https://docs.docker.com/engine/reference/commandline/inspect/
  
* List of mounts: <pre>docker inspect -f '{{ .Mounts }}' CONTAINER_NAME</pre><ref>https://stackoverflow.com/questions/30133664/how-do-you-list-volumes-in-docker-containers</ref>
 
* [[Docker Start configuration behavior and restart policy|Restart policy]]: <pre>docker inspect --format '{{json .HostConfig.RestartPolicy}}' CONTAINER_NAME</pre><ref>https://stackoverflow.com/questions/43108227/is-it-possible-to-show-the-restart-policy-of-a-running-docker-container</ref>
 
  
 +
docker inspect xxxxxx | grep Os
 +
 +
 +
docker inspect xxxxxx | grep -i [[memory]]
 +
            "[[Memory]]": 37748736000,
 +
            "[[KernelMemory]]": 0,
 +
            "[[KernelMemoryTCP]]": 0,
 +
            "[[MemoryReservation]]": 0,
 +
            "[[MemorySwap]]": 75497472000,
 +
            "[[MemorySwappiness]]": null,
 +
 +
 +
 +
[[Docker Start configuration behavior and restart policy|Restart policy]]: <ref>https://stackoverflow.com/questions/43108227/is-it-possible-to-show-the-restart-policy-of-a-running-docker-container</ref>
 +
 +
* <code><nowiki>docker inspect --format '{{json .HostConfig.RestartPolicy}}' CONTAINER_NAME</nowiki></code>
 +
 +
[[Docker network|Network]]
 +
* <code>docker inspect your-container | grep [[NetworkMode]]</code>
 +
 +
== Volumes and mounts ==
 +
* List of mounts: <ref>https://stackoverflow.com/questions/30133664/how-do-you-list-volumes-in-docker-containers</ref>
 +
<code><nowiki>docker inspect -f '{{ .Mounts }}' CONTAINER_NAME</nowiki></code>
 +
<code><nowiki>docker inspect -f '{{ json .Mounts }}' CONTAINER_NAME | jq .</nowiki></code>
 +
<code><nowiki>docker inspect -f '{{ json .Mounts }}' CONTAINER_NAME | python -m json.tool</nowiki></code>
 +
 +
See also: <code>[[docker volume inspect]]</code>
 +
 +
== [[IP]] ==
 +
* <code>[[docker inspect]] CONTAINER_NAME | grep [[IPAddress]]</code>
 
<pre>
 
<pre>
docker inspect example output on a CONTAINER_ID:
+
docker inspect --format "{{ .NetworkSettings.IPAddress }}"
              $ docker inspect d2cc496561d6
+
</pre>
              [{
+
 
              "Id": "d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47",
+
== [[Start]] contiguration ==
              "Created": "2015-06-08T16:18:02.505155285Z",
+
* <code>docker inspect -f "{{ .HostConfig.[[RestartPolicy]]}}" $([[docker ps -a]] -q)</code>
              "Path": "bash",
+
 
              "Args": [],
+
== [[Docker inspect example]] ==
              "State": {
+
 
                  "Running": false,
+
== Redirecting container logs to [[syslog]] ==
                  "Paused": false,
+
docker inspect <container_id|container_name> | grep -A 5 LogConfig
                  "Restarting": false,
+
 
                  "OOMKilled": false,
+
 
                  "Dead": false,
+
"[[LogConfig]]": {
                  "Pid": 0,
+
  "Type": "syslog"
                  "ExitCode": 0,
+
  "Config": {}
                  "Error": "",
+
}
                  "StartedAt": "2015-06-08T16:18:03.643865954Z",
 
                  "FinishedAt": "2015-06-08T16:57:06.448552862Z"
 
              },
 
              "Image": "ded7cd95e059788f2586a51c275a4f151653779d6a7f4dad77c2bd34601d94e4",
 
              "NetworkSettings": {
 
                  "Bridge": "",
 
                  "SandboxID": "6b4851d1903e16dd6a567bd526553a86664361f31036eaaa2f8454d6f4611f6f",
 
                  "HairpinMode": false,
 
                  "LinkLocalIPv6Address": "",
 
                  "LinkLocalIPv6PrefixLen": 0,
 
                  "Ports": {},
 
                  "SandboxKey": "/var/run/docker/netns/6b4851d1903e",
 
                  "SecondaryIPAddresses": null,
 
                  "SecondaryIPv6Addresses": null,
 
                  "EndpointID": "7587b82f0dada3656fda26588aee72630c6fab1536d36e394b2bfbcf898c971d",
 
                  "Gateway": "172.17.0.1",
 
                  "GlobalIPv6Address": "",
 
                  "GlobalIPv6PrefixLen": 0,
 
                  "IPAddress": "172.17.0.2",
 
                  "IPPrefixLen": 16,
 
                  "IPv6Gateway": "",
 
                  "MacAddress": "02:42:ac:12:00:02",
 
                  "Networks": {
 
                      "bridge": {
 
                          "NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812",
 
                          "EndpointID": "7587b82f0dada3656fda26588aee72630c6fab1536d36e394b2bfbcf898c971d",
 
                          "Gateway": "172.17.0.1",
 
                          "IPAddress": "172.17.0.2",
 
                          "IPPrefixLen": 16,
 
                          "IPv6Gateway": "",
 
                          "GlobalIPv6Address": "",
 
                          "GlobalIPv6PrefixLen": 0,
 
                          "MacAddress": "02:42:ac:12:00:02"
 
                      }
 
                  }
 
  
              },
+
== OOM ==
              "ResolvConfPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/resolv.conf",
+
{{Docker inspect OOM}}
              "HostnamePath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/hostname",
+
 
              "HostsPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/hosts",
+
 
              "LogPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47-json.log",
+
docker inspect [[your_container]] | grep [[mem]]
              "Name": "/adoring_wozniak",
 
              "RestartCount": 0,
 
              "Driver": "devicemapper",
 
              "MountLabel": "",
 
              "ProcessLabel": "",
 
              "Mounts": [
 
                {
 
                  "Source": "/data",
 
                  "Destination": "/data",
 
                  "Mode": "ro,Z",
 
                  "RW": false
 
              "Propagation": ""
 
                }
 
              ],
 
              "AppArmorProfile": "",
 
              "ExecIDs": null,
 
              "HostConfig": {
 
                  "Binds": null,
 
                  "ContainerIDFile": "",
 
                  "Memory": 0,
 
                  "MemorySwap": 0,
 
                  "CpuShares": 0,
 
                  "CpuPeriod": 0,
 
                  "CpusetCpus": "",
 
                  "CpusetMems": "",
 
                  "CpuQuota": 0,
 
                  "BlkioWeight": 0,
 
                  "OomKillDisable": false,
 
                  "Privileged": false,
 
                  "PortBindings": {},
 
                  "Links": null,
 
                  "PublishAllPorts": false,
 
                  "Dns": null,
 
                  "DnsSearch": null,
 
                  "DnsOptions": null,
 
                  "ExtraHosts": null,
 
                  "VolumesFrom": null,
 
                  "Devices": [],
 
                  "NetworkMode": "bridge",
 
                  "IpcMode": "",
 
                  "PidMode": "",
 
                  "UTSMode": "",
 
                  "CapAdd": null,
 
                  "CapDrop": null,
 
                  "RestartPolicy": {
 
                      "Name": "no",
 
                      "MaximumRetryCount": 0
 
                  },
 
                  "SecurityOpt": null,
 
                  "ReadonlyRootfs": false,
 
                  "Ulimits": null,
 
                  "LogConfig": {
 
                      "Type": "json-file",
 
                      "Config": {}
 
                  },
 
                  "CgroupParent": ""
 
              },
 
              "GraphDriver": {
 
                  "Name": "devicemapper",
 
                  "Data": {
 
                      "DeviceId": "5",
 
                      "DeviceName": "docker-253:1-2763198-d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47",
 
                      "DeviceSize": "171798691840"
 
                  }
 
              },
 
              "Config": {
 
                  "Hostname": "d2cc496561d6",
 
                  "Domainname": "",
 
                  "User": "",
 
                  "AttachStdin": true,
 
                  "AttachStdout": true,
 
                  "AttachStderr": true,
 
                  "ExposedPorts": null,
 
                  "Tty": true,
 
                  "OpenStdin": true,
 
                  "StdinOnce": true,
 
                  "Env": null,
 
                  "Cmd": [
 
                      "bash"
 
                  ],
 
                  "Image": "fedora",
 
                  "Volumes": null,
 
                  "VolumeDriver": "",
 
                  "WorkingDir": "",
 
                  "Entrypoint": null,
 
                  "NetworkDisabled": false,
 
                  "MacAddress": "",
 
                  "OnBuild": null,
 
                  "Labels": {},
 
                  "Memory": 0,
 
                  "MemorySwap": 0,
 
                  "CpuShares": 0,
 
                  "Cpuset": "",
 
                  "StopSignal": "SIGTERM"
 
              }
 
              }
 
              ]
 
</pre>
 
  
 +
== Related commands ==
 +
* <code>[[docker image inspect]]</code>
 +
* <code>[[docker container inspect]]</code>
 +
* <code>[[docker volume inspect]]</code>
 +
* [[docker buildx inspect]]
  
 
== See also ==
 
== See also ==
* {{docker}}
+
* {{docker inspect}}
 
+
* {{docker cmd}}
  
[[Category:Cloud computing]]
+
[[Category:Docker]]
[[Category:Software development]]
 
[[Category:Server administration]]
 
  
 
{{CC license}}
 
{{CC license}}
 
Original Source: https://en.wikiversity.org/wiki/DevOps/Docker/docker_inspect
 
Original Source: https://en.wikiversity.org/wiki/DevOps/Docker/docker_inspect

Latest revision as of 10:10, 12 May 2023

docker inspect CONTAINER_ID|IMAGE_ID (also available for: container, image, volume, network, node, service, or task)


docker inspect xxxxxx | grep Os


docker inspect xxxxxx | grep -i memory
           "Memory": 37748736000,
           "KernelMemory": 0,
           "KernelMemoryTCP": 0,
           "MemoryReservation": 0,
           "MemorySwap": 75497472000,
           "MemorySwappiness": null,


Restart policy: [1]

  • docker inspect --format '{{json .HostConfig.RestartPolicy}}' CONTAINER_NAME

Network

Volumes and mounts[edit]

  • List of mounts: [2]
docker inspect -f '{{ .Mounts }}' CONTAINER_NAME
docker inspect -f '{{ json .Mounts }}' CONTAINER_NAME | jq .
docker inspect -f '{{ json .Mounts }}' CONTAINER_NAME | python -m json.tool

See also: docker volume inspect

IP[edit]

docker inspect --format "{{ .NetworkSettings.IPAddress }}"

Start contiguration[edit]

Docker inspect example[edit]

Redirecting container logs to syslog[edit]

docker inspect <container_id|container_name> | grep -A 5 LogConfig


"LogConfig": {
  "Type": "syslog"
  "Config": {}
}

OOM[edit]

docker inspect grafana | grep -i OOM
           "OOMKilled": false,
           "OomScoreAdj": 0,
           "OomKillDisable": false,


docker inspect your_container | grep mem

Related commands[edit]

See also[edit]

Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy.

Original Source: https://en.wikiversity.org/wiki/DevOps/Docker/docker_inspect

Advertising: