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": "172.17.0.2",
                    "IPAddress": "172.17.0.2",
                    "IPAddress": "172.19.0.4",
                    "IPAddress": "172.18.0.3",
                    "IPAddress": "172.20.0.2",
# 

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
172.17.0.2
# 

Thanks in advance

you must look on bridge0

Bridge network driver | Docker Docs

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": [
                        "457165ff1c3e"
                    ],
                    "NetworkID": "5ca1ed563b448a9da008810828be663c4b9febf6c7b1ef6888ab308cb9d0b020",
                    "EndpointID": "4ba475c3361bdf9f2a13bb65d2a3b04046e4d81cc4371b921f9b39cbae962974",
                    "Gateway": "172.20.0.1",
                    "IPAddress": "172.20.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:14:00:02"
                }
# docker inspect elk | grep -A15 nginx_default | grep IPAddress
                    "IPAddress": "172.20.0.2",
# 

as elk container is part of several networks:

# docker inspect elk | grep -c _default
3
# 

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 (https://golang.org/pkg/text/template/).

something like this

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