Docker Community Forums

Share and learn in the Docker community.

Docker inspect --format

I have container that is connected to few bridge networks and because of that it has more then 1 IPAddress:

# docker inspect --format '' elk | grep \"IPAddress
            "IPAddress": "",
                    "IPAddress": "",
                    "IPAddress": "",
                    "IPAddress": "",
                    "IPAddress": "",

I’m trying to figure out how to use docker inspect --format to get IPAddress of specific network instead of just first IPAddress like I have so far:

# docker inspect --format '{{ .NetworkSettings.IPAddress }}' elk

Thanks in advance

you must look on bridge0

I’m not looking customize bridge, all I need to be able to cherry pick IPAddress of specific network, say: ngnix_default:

# docker inspect elk | grep -A15 nginx_default
                "nginx_default": {
                    "IPAMConfig": {},
                    "Links": null,
                    "Aliases": [
                    "NetworkID": "5ca1ed563b448a9da008810828be663c4b9febf6c7b1ef6888ab308cb9d0b020",
                    "EndpointID": "4ba475c3361bdf9f2a13bb65d2a3b04046e4d81cc4371b921f9b39cbae962974",
                    "Gateway": "",
                    "IPAddress": "",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:14:00:02"
# docker inspect elk | grep -A15 nginx_default | grep IPAddress
                    "IPAddress": "",

as elk container is part of several networks:

# docker inspect elk | grep -c _default

I’m not sure how bridge customization is going to help me here, I’d rather learn how to use inspect.

Unless, I’m completely off, maybe you can provide an example?

Thanks again!

Ive quoted the article for bridge0 customization.

@alexus I bet you could do that using Go template range (

something like this

$ docker inspect -f '{{range $i, $n := .NetworkSettings.Networks}}{{$n.IPAddress}}{{end}}' <id>