How to change docker0 ip address on centos 7

Hi community
Please, I have this issue:
In my company, we are using the 172.x.x.x networks (for VPN and other stuff) so I need to change the default subnet in docker0 network interface in my Centos 7.9 server.

  1. One possible solution that working is running is this:
    ip addr add dev docker0
    ip addr del dev docker0
    The troubble is that wen I restart the docker service, the docker0 interface back to the so, when I create or run a container, that container use the network.

  2. Several forums are saying to add the following to /etc/docker/daemon.json:
    “bip”: “”
    I been trying adding the bip parameter, but error in the restart of docker.

  3. I try to edit /lib/systemd/system/docker.service before start Docker. Add --bip “” at the end of line ExecStart=/usr/bin/dockerd.
    systemctl daemon-reload
    systemctl start docker
    Still error in the restart of docker :frowning:

Any ideas about how can I change permannent the subnet parameter in my Centos 7.9 server ¿?

If you don’t tell us what the errror messages were, we can’t recommend a solution. Changing “bip” was the right way. Do you have error messages?

Thanks @rimelek
Actually, I haved lost the touch…
I looked the error log and I find the troubble…
When I defined the network in the daemon.json, I was using a bad format. This is how working in Centos 7.9:


Thank you for sharing the working solution.

I edited your post. Please, next time format your post according to the following guide: How to format your forum posts
In short: please, use </> button to share codes, terminal outputs, error messages or anything that can contain special characters which would be interpreted by the MarkDown filter. Use the preview feature to make sure your text is formatted as you would expect it and check your post after you have sent it so you can still fix it.