Change the Default Docker Subnet with SystemD

Docker uses the default subnet for container networking.

This will become a problem if you use the same subnet for your local network.

To change the default subnet on the docker0 interface with systemd (CentOS 7), create the following directory:

$ sudo mkdir -p /etc/systemd/system/docker.service.d/

Create the configuration file /etc/systemd/system/docker.service.d/override.conf with the following content:

ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --bip

Where is your new Docker subnet.

Reload systemd manager configuration:

$ sudo systemctl daemon-reload

Restart Docker service:

$ sudo systemctl restart docker.service


$ ip addr show dev docker0
4: docker0:  mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:c8:21:8c:19 brd ff:ff:ff:ff:ff:ff
    inet brd scope global docker0
       valid_lft forever preferred_lft forever

Leave a Reply

Your email address will not be published.