brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: default-address-pools stops Docker networks from clashing with your LAN

Docker
~/tips/tip-docker-default-address-pools

"default-address-pools": [

Tell Docker which IP ranges it may use for new networks.

Every Compose project gets its own network, and Docker picks the ranges itself. Sooner or later one of them lands on the same range as your VPN or office network, and that part of the network becomes unreachable from the host.

In /etc/docker/daemon.json you set the pools Docker may take subnets from:

{
  "default-address-pools": [
    { "base": "192.0.2.0/24", "size": 28 }
  ]
}
sudo systemctl restart docker

The addresses here are documentation placeholders; use a private range that is free on your networks. With this pool, each new network gets a /28 out of 192.0.2.0/24: sixteen networks with room for about a dozen containers each. A real pool is usually a /16 split into /24 blocks, giving 256 networks. That size matters too: the default pools hand out larger blocks than a home server will ever need.

Pick a range that is not used anywhere you connect to: not your LAN, not a VPN you dial into, not a customer network. I’d check the routes on the host with ip route before choosing.

The setting only affects networks created after the restart. Existing networks keep their old ranges until you remove and recreate them, which for Compose means docker compose down and up per project. The default docker0 bridge has its own bip setting and is not covered by the pools.

Further reading: dockerd reference: default-address-pools

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link