I built a small bridge network and connected it to a handful of containers.
I receive a lot of output when I run the docker network inspect webservers command, and I'd like to filter out the majority of it.
For example, I'd like to examine each container's IPv4Address value. This is an example of a json block:
"Containers": {
"2868125fa1f1b97fd765f7d6bd61d1d8eff3e9cb16ea6c3d5625ce1d331932b9": {
"Name": "tomcat",
"EndpointID": "36d35901e11d4b5be5336aa90e5161eca82c3a24f3661901461f3bfed2b2a2d3",
"MacAddress": "02:42:ac:14:00:03",
"IPv4Address": "172.20.0.3/16",
"IPv6Address": ""
},
So I tried using ".Containers.IPv4Address" to retrieve IP address information, but the output was "no value":
kamo@ubox:~$ docker inspect -f '{{ .Containers.IPv4Address }}' webservers
<no value>
kamo@ubox:~$
I also experimented with the "range" argument:
docker inspect -f '{{ range .Containers.IPv4Address }} {{ .IPv4Address }} {{ end }}' webservers
However, it created no output at all.
So, how can I use the --format parameter to obtain IPv4Address information?
What if I wanted to get two values out of each container: "Name" and "IPv4Address"?