Changing default subnet for docker custom networks

Our internal network has the range 172.20.0.0/16 reserved for internal purposes and docker uses the 172 range by default for its internal networking. I can reset the bridge to live in 192.168 by providing the bip setting to the daemon:

➜  ~ sudo cat /etc/docker/daemon.json
{
  "bip": "192.168.2.1/24"
}

➜  ~ ifconfig                        
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
    inet 192.168.2.1  netmask 255.255.255.0  broadcast 0.0.0.0

However, when creating new custom networks via docker network create or by defining them in the networks sections of the docker-compose.yaml these are still created in 172, thus eventually clashing with 172.20:

  • How can I develop in docker container with intellij?
  • Dokku DigitalOcean Deploy (Cannot access Rails Sample App)
  • Docker compose: command after docker-compose run command
  • Why am I seeing docker.io infront of the docker images repository name?
  • Cannot install uwsgi on Alpine
  • Does a restart in a Dockerfile make sense?
  • ➜  ~ docker network create foo
    610fd0b7ccde621f87d40f8bcbed1699b22788b70a75223264bb14f7e63f5a87
    ➜  ~ docker network inspect foo | grep Subnet
                    "Subnet": "172.17.0.0/16",
    ➜  ~ docker network create foo1              
    d897eab31b2c558517df7fb096fab4af9a4282c286fc9b6bb022be7382d8b4e7
    ➜  ~ docker network inspect foo1 | grep Subnet
                    "Subnet": "172.18.0.0/16",
    

    I understand I can provide the subnet value to docker network create, but I rather want all such subnets created under 192.168.*.

    How can one configure dockerd to do this automatically?

  • OpenStack and Docker
  • Python script for creating docker container using Remote API
  • List containers in the same docker-compose
  • How to achieve build isolation and caching simultaneously?
  • Docker alpine image's basic commands are not working
  • How to setup multiple docker containers for multiple developers on the same host?
  • One Solution collect form web for “Changing default subnet for docker custom networks”

    I have just found out that according to the following (still open) pull request, this is still not possible: https://github.com/moby/moby/pull/29376

    I will be more than happy to delete this “answer” if you guys know better.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.