Commandes Linux : docker container inspect

DOCKER CONTAINER INSPECT

Commande : docker container inspect
Usage:	docker container inspect [OPTIONS] CONTAINER [CONTAINER...]

Display detailed information on one or more containers

Options:
  -f, --format string   Format the output using the given Go template
  -s, --size            Display total file sizes

 

Afficher la configuration d’un container :

docker container inspect [-f '["Texte"] {{[json] .Path.To.Information}}'] container

Equivaut à :
docker inspect --type="container" [-f '["Texte"] {{[json] .Path.To.Information}}'] object
Pour plus d’informations : Docker Docs – Format command and log output
ex :

$ docker container inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' youthful_wozniak
172.17.0.2
$ docker container inspect -f 'MAC address : {{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' youthful_wozniak
MAC address : 02:42:ac:11:00:02
$ docker container inspect -f '{{.LogPath}}' youthful_wozniak
/var/lib/docker/containers/a624e8d3eadfc974f5d5534e1e7f10ba10b69dc5d8ee9f8c53f8477b8eb127c4/a624e8d3eadfc974f5d5534e1e7f10ba10b69dc5d8ee9f8c53f8477b8eb127c4-json.log
$ docker container inspect -f '{{.Config.Image}}' youthful_wozniak
darwinos/repotest:web_server-v1.0
$ docker container inspect -f '{{json .Config}}' youthful_wozniak
{"Hostname":"a624e8d3eadf","Domainname":"","User":"","AttachStdin":false,"AttachStdout":true,"AttachStderr":true,"ExposedPorts":{"80/tcp":{}},"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","NGINX_VERSION=1.15.0-1~stretch","NJS_VERSION=1.15.0.0.2.1-1~stretch"],"Cmd":["nginx","-g","daemon off;"],"ArgsEscaped":true,"Image":"darwinos/repotest:web_server-v1.0","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":{"maintainer":"NGINX Docker Maintainers "},"StopSignal":"SIGTERM"}
$ docker container inspect -f '{{.Config}}' youthful_wozniak
{a624e8d3eadf   false true true map[80/tcp:{}] false false false [PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin NGINX_VERSION=1.15.0-1~stretch NJS_VERSION=1.15.0.0.2.1-1~stretch] [nginx -g daemon off;]  true darwinos/repotest:web_server-v1.0 map[]  [] false  [] map[maintainer:NGINX Docker Maintainers ] SIGTERM  []}
$ docker container inspect -f '{{ json .GraphDriver }}' c1 | jq
{
  "Data": {
    "LowerDir": "/var/lib/docker/overlay2/33d48d040eabd0501c2b4c472665b1943604c5c3cd9520f7553652242e314fbe-init/diff:/var/lib/docker/overlay2/205b956c7af855baadb58e88d4c82f342dc735e9804c6ad842da64775940d461/diff",
    "MergedDir": "/var/lib/docker/overlay2/33d48d040eabd0501c2b4c472665b1943604c5c3cd9520f7553652242e314fbe/merged",
    "UpperDir": "/var/lib/docker/overlay2/33d48d040eabd0501c2b4c472665b1943604c5c3cd9520f7553652242e314fbe/diff",
    "WorkDir": "/var/lib/docker/overlay2/33d48d040eabd0501c2b4c472665b1943604c5c3cd9520f7553652242e314fbe/work"
  },
  "Name": "overlay2"
}
$ docker container inspect --format '{{ .Id }}' 450475a
450475ae3fd3332d7fd8a1d6dfcdcf43bd202f8458f0f1182b72fa73d6399fb1
$ docker container inspect --format '{{ .NetworkSettings.IPAddress }}' 450475a
172.17.0.2
$ docker container inspect --format '{{ json .State }}' hardcore_heisenberg
{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":11579,"ExitCode":0,"Error":"","StartedAt":"2018-10-11T15:15:04.684322824Z","FinishedAt":"0001-01-01T00:00:00Z"}
$ docker container inspect --format '{{ json .State }}' hardcore_heisenberg | jq
{
  "Status": "running",
  "Running": true,
  "Paused": false,
  "Restarting": false,
  "OOMKilled": false,
  "Dead": false,
  "Pid": 11579,
  "ExitCode": 0,
  "Error": "",
  "StartedAt": "2018-10-11T15:15:04.684322824Z",
  "FinishedAt": "0001-01-01T00:00:00Z"
}
$ docker container inspect --format '{{ json .State }}' hardcore_heisenberg | python -m json.tool
{
  "Status": "running",
  "Running": true,
  "Paused": false,
  "Restarting": false,
  "OOMKilled": false,
  "Dead": false,
  "Pid": 11579,
  "ExitCode": 0,
  "Error": "",
  "StartedAt": "2018-10-11T15:15:04.684322824Z",
  "FinishedAt": "0001-01-01T00:00:00Z"
}

 

Fermer le menu