How to fix the subnet configuration
Hi everyone, I have an issue with some containers due to the subnet changing the scope and I'm not sure how to handle it. Last friday after an update all the subnet changed broking my services.
The first issue is with Home Assistant: to reach it from WAN I had to set in the configuration file the allowed proxy IPs. I set the subnet of the network that it shares with Cloudflared, if this last container changes IP there is no problem, but when the scope went from 172.16.0.0/16 to 172.20.0.0/16 I couldn't reach it anymore.
The second issue is with Tailscale's docker, I use it with the SERVE function to reach other containers. With the containers I use the name of the services and it works even if the subnet change, but to reach the host I need to set the gateway IP, which went from 172.18.0.1 to 172.23.0.1
I added this section in the compose file under the network section:
networks
cloudflared_net
[...]
IPAM:
configuration:
- subnet: 172.16.0.0/16
Now the networks are created everytime with the same subnet, but I'm not sure if there is a better way to handle it. Is it possible that docker now assignes the same subnet to one of the other networks and this create other problems? How would you manage it?
Thank you
SOLUTION(?): Following the comments I edit the file /etc/docker/daemon.json adding this 2 sections:
"bip": "172.17.0.1/24",
"default-address-pools": [
{
"base": "172.16.0.0/16",
"size": 24
}
]
I got crazy and lost a couple of hours because after the change docker didn't start anymore, I found that for the default bridge you have to write the IP of the gateway (172.17.0.1) and not of the network (172.17.0.0) like in the second section and it's not specified in the docker wiki, fml.