Docker Compose runs out of address pools for new networks
ERROR: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the networkShort answer
Docker hands every new network a subnet from its default address pools. The error means no free subnet is left, or the free ones overlap something else. Remove unused networks first. If you really need many networks, define larger or different pools in daemon.json, or give the Compose network an explicit subnet.
Fix it fast
1Find out which cause you have
Count how many networks exist, and look at one in detail to see its subnet.
docker network ls docker network inspect bridge2Match what you see, then jump to its fix
- 1
docker network ls shows many project_default networks that no container usesOld networks from stopped projects are still allocatedFix - 2
The network list is full of networks you still need, and the error appears when you start one more projectThe default pools are too small for the number of networksFix - 3
Only one project fails, and you know a range that is freeThe project needs one fixed subnet instead of an automatic oneFix
- 1
What does the error look like?
ERROR: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network
Cause 1 of 3
Old networks from stopped projects are still allocated
1Check
Each Compose project creates a network and keeps its subnet until the network is removed. Unused ones can pile up.
docker network ls2Fix
Remove networks that no container references. The prune command does exactly that, and asks before it deletes.
docker network prune3Verify
Bring the project up again.
docker compose up -dConfirmed by docs.docker.com
Cause 2 of 3
The default pools are too small for the number of networks
1Check
The daemon takes subnets from default-address-pools. Look at what the daemon currently uses.
cat /etc/docker/daemon.json2Fix
Add pools in /etc/docker/daemon.json with a base range and a size per network, then restart the daemon. The example from the dockerd reference uses a /16 base split into /24 networks. Choose ranges that do not collide with your LAN or VPN.
{
"default-address-pools": [
{ "base": "172.30.0.0/16", "size": 24 },
{ "base": "172.31.0.0/16", "size": 24 }
]
}
sudo systemctl restart docker3Verify
Start the project that failed.
docker compose up -dConfirmed by docs.docker.com
Cause 3 of 3
The project needs one fixed subnet instead of an automatic one
1Check
Compose lets a network declare its own subnet under ipam, so it skips the automatic choice.
docker compose config2Fix
Set the subnet in the Compose file, using a range that is free on this host.
networks:
default:
ipam:
config:
- subnet: 172.28.0.0/163Verify
The network is created with that subnet.
docker compose up -d
docker network lsConfirmed by docs.docker.com
How do I stop it coming back?
- Run docker compose down when a project is finished, so its network is released.
- Pick address pools once for the host and write them down next to your VPN ranges.
- Avoid creating a new network per CI job on a shared Docker host.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
sam local fails: Running AWS SAM projects locally requires Docker
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
sam local start-api and sam local invoke run your function inside a Docker container, so SAM stops if it cannot talk to Docker.
3 causes, each with a fixServers
dnf fails to download repo metadata in a CentOS 8 Docker build
The same Dockerfile built fine before 2022
CentOS Linux 8 reached end of life on 31 December 2021 and its content left the mirrors.
2 causes, each with a fixServers
pip install confluent-kafka fails because librdkafka/rdkafka.h is missing
pip stops while building confluent-kafka from source
The error means pip is compiling confluent-kafka from source, and the compiler cannot find the librdkafka C headers.
3 causes, each with a fixServers
Cypress says the npm package is installed but the binary is missing
Cypress binary is missing after npm install in CI or in a Docker build
The npm package is only a launcher.
3 causes, each with a fixServers
A dev container port does not open in the browser when Docker runs on a remote host
If your application only accepts calls from localhost, it will reject connections from published ports
Three things usually break it: the app listens only on localhost inside the container, so published ports are rejected; you open the container port instead of the mapped localhost port VS Code shows; or you changed appPort or a Compose ports list and did not rebuild.
3 causes, each with a fix