From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- ...ne%2Freference%2Fcommandline%2Finspect%2Findex.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 devdocs/docker/engine%2Freference%2Fcommandline%2Finspect%2Findex.html (limited to 'devdocs/docker/engine%2Freference%2Fcommandline%2Finspect%2Findex.html') diff --git a/devdocs/docker/engine%2Freference%2Fcommandline%2Finspect%2Findex.html b/devdocs/docker/engine%2Freference%2Fcommandline%2Finspect%2Findex.html new file mode 100644 index 00000000..c999cd8d --- /dev/null +++ b/devdocs/docker/engine%2Freference%2Fcommandline%2Finspect%2Findex.html @@ -0,0 +1,18 @@ +

docker inspect


Return low-level information on Docker objects

Usage

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

Refer to the options section for an overview of available OPTIONS for this command.

Description

Docker inspect provides detailed information on constructs controlled by Docker.

By default, docker inspect will render results in a JSON array.

For example uses of this command, refer to the examples section below.

Options

Name, shorthand Default Description
+--format , -f + Format the output using the given Go template
+--size , -s + Display total file sizes if the type is container
--type Return JSON for specified type

Examples

Get an instance’s IP address

For the most part, you can pick out any field from the JSON in a fairly straightforward manner.

$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID
+

Get an instance’s MAC address

$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID
+

Get an instance’s log path

$ docker inspect --format='{{.LogPath}}' $INSTANCE_ID
+

Get an instance’s image name

$ docker inspect --format='{{.Config.Image}}' $INSTANCE_ID
+

List all port bindings

You can loop over arrays and maps in the results to produce simple text output:

$ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
+

Find a specific port mapping

The .Field syntax doesn’t work when the field name begins with a number, but the template language’s index function does. The .NetworkSettings.Ports section contains a map of the internal port mappings to a list of external address/port objects. To grab just the numeric public port, you use index to find the specific port map, and then index 0 contains the first object inside of that. Then we ask for the HostPort field to get the public address.

$ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
+

Get a subsection in JSON format

If you request a field which is itself a structure containing other fields, by default you get a Go-style dump of the inner values. Docker adds a template function, json, which can be applied to get results in JSON format.

$ docker inspect --format='{{json .Config}}' $INSTANCE_ID
+
+

+ © 2019 Docker, Inc.
Licensed under the Apache License, Version 2.0.
Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.
Docker, Inc. and other parties may also have trademark rights in other terms used herein.
+ https://docs.docker.com/engine/reference/commandline/inspect/ +

+
-- cgit v1.2.3