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: <NO-CARRIER,BROADCAST,MULTICAST,UP> 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

2 thoughts on “Change the Default Docker Subnet with SystemD

  1. Thank you. It works. is bad example because this is not private IP address range. This is internet range
    Some colleagues may use this config “as is” and face issue

Leave a Reply

Your email address will not be published. Required fields are marked *