Docker Community Forums

Share and learn in the Docker community.

Inspection filters in JSON format

Hi

Brand new to docker and working my way through the documentation. I’m currently looking at the networking stuff and see that I can inspect the bridge network with:

docker network inspect bridge

One of the nodes being Containers:

        "Containers": {
        "ebe3cd3e33edb54e91aa94bdf4af2076c45b246a046f602e17cfb6c33d2f0d27": {
            "Name": "networktest",
            "EndpointID": "c90398339875ba649cc86513951f84fcf79f6e0ccb430d2011442fc88ddd73f8",
            "MacAddress": "02:42:ac:11:00:02",
            "IPv4Address": "172.17.0.2/16",
            "IPv6Address": ""
        }
    },

I was wondering if it is possible to get the names of all of the containers by wildcarding the container (I assume the unnamed key is a digest ??).

If I try this:

docker network inspect --format='{{json .Containers.ebe3cd3e33edb54e91aa94bdf4af2076c45b246a046f602e17cfb6c33d2f0d27.Name}}' bridge
"networktest"

Then I can retrieve the name “networktest”, but how could I wildcard this to return all names regardless of how many containers are on the network?

Any online docs relating to filtering around the --format option would be a great help as well.

Thanks in advance

Steady

Did you ever figure this out? Just started using custom networks with compose and this would be pretty handy.

Came across this question as I was trying to figure it out for myself. Ended up figuring it out based off the documentation:

Basically range works as an iterator function

Leaving this here as a potential solution for anyone else that comes across this:

docker network inspect bridge --format='{{range .Containers}}{{println .Name}}{{end}}'
1 Like