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 192.168.1.1/24
    ip addr del dev docker0 172.17.0.1/16
    The troubble is that wen I restart the docker service, the docker0 interface back to the 172.17.0.1 so, when I create or run a container, that container use the 172.17.0.0/16 network.

  2. Several forums are saying to add the following to /etc/docker/daemon.json:
    {
    “bip”: “192.168.1.1/24”
    }
    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 “192.168.1.1/24” 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:

{
  "default-address-pools":
  [
    {"base":"192.168.1.1/24","size":24}
  ]
}

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.