How to get docker0 ip address platform independently

docker0 network interface is associated with the default docker network bridge.
You can access info about it with the docker network inspect bridge.
You can use the --format option to get specific value:

$ docker network inspect bridge --format='{{json .IPAM.Config}}'
[{"Subnet":"172.17.0.0/16","Gateway":"172.17.0.1"}]

Get just the gateway ip with:

$ docker network inspect bridge --format='{{(index .IPAM.Config 0).Gateway}}'
172.17.0.1

Tags:

Docker