Error: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network

Ubuntu 23.10
Docker Version: 25.0.0

I created another folder (as i do for all docker compose files) in /home and put the docker-compose.yml file in it.

Then I ran docker compose up and received this error:

$ sudo docker compose up -d
[+] Running 1/0
 ✘ Network actualbudget_default  Error                                     0.0s 
failed to create network actualbudget_default: Error response from daemon: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network

When I use docker network ls, I see the following:

$ sudo docker network ls
NETWORK ID     NAME                        DRIVER    SCOPE
e4b843e75057   audiobookshelf_default      bridge    local
c082fc90c240   bridge                      bridge    local
b6131428cb15   budgetzen_default           bridge    local
cb8119d1f760   changedetection_default     bridge    local
0e288b0a27ed   dozzle_default              bridge    local
1b5b146c2bf5   duplicati_default           bridge    local
687f3b1e0651   filebrowser_default         bridge    local
a75994298ed0   flaresolverr_default        bridge    local
1ea38e95c1ea   freshrss_default            bridge    local
a3111e8cdbd9   homepage_default            bridge    local
1d8dd8e623df   host                        host      local
38d729e3b354   immich_default              bridge    local
81436f127ba8   lidarr_default              bridge    local
a83ac4972283   linkding_default            bridge    local
f4998ea9e384   maintainerr_default         bridge    local
f710b39ebac3   nitter_default              bridge    local
9e9cc1014617   none                        null      local
a80f5ef0dac8   overseerr_default           bridge    local
6b5d2fd02cbe   paperless_default           bridge    local
66ccda4a22bb   plex_default                bridge    local
58c187461c33   portainer_default           bridge    local
406d408d24ff   prowlarr_default            bridge    local
7bdcb68e56b9   qbittorrent_default         bridge    local
4743c50e54ab   radarr_default              bridge    local
2f71b2d5e526   readarr_default             bridge    local
3a4d754ff0df   sabnzbd_default             bridge    local
622bff0c9c72   sonarr_default              bridge    local
723be40145c7   speedtest-tracker_default   bridge    local
36227e17f2f8   stirling_default            bridge    local
5e9bfa5a5c6d   tautulli_default            bridge    local
487813c89507   uptime-kuma_default         bridge    local
d7d157c6cabf   watchtower_default          bridge    local

I tried restarting docker, and my ubuntu computer, and that didn’t fix the issue.

After restart the computer I ran the following:

$ docker network create test
Error response from daemon: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network

I tried route:

$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         _gateway        0.0.0.0         UG    100    0        0 eno1
link-local      0.0.0.0         255.255.0.0     U     1000   0        0 eno1
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
172.18.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-a83ac4972283
172.19.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-58c187461c33
172.20.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-66ccda4a22bb
172.21.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-d7d157c6cabf
172.22.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-3a4d754ff0df
172.23.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-622bff0c9c72
172.24.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-406d408d24ff
172.25.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-687f3b1e0651
172.26.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-4743c50e54ab
172.27.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-81436f127ba8
172.28.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-2f71b2d5e526
172.29.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-a80f5ef0dac8
172.30.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-f4998ea9e384
172.31.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-a3111e8cdbd9
192.168.0.0     0.0.0.0         255.255.240.0   U     0      0        0 br-5e9bfa5a5c6d
192.168.16.0    0.0.0.0         255.255.240.0   U     0      0        0 br-723be40145c7
192.168.32.0    0.0.0.0         255.255.240.0   U     0      0        0 br-36227e17f2f8
192.168.50.0    0.0.0.0         255.255.255.0   U     100    0        0 eno1
192.168.64.0    0.0.0.0         255.255.240.0   U     0      0        0 br-6b5d2fd02cbe
192.168.80.0    0.0.0.0         255.255.240.0   U     0      0        0 br-1ea38e95c1ea
192.168.96.0    0.0.0.0         255.255.240.0   U     0      0        0 br-0e288b0a27ed
192.168.112.0   0.0.0.0         255.255.240.0   U     0      0        0 br-38d729e3b354
192.168.128.0   0.0.0.0         255.255.240.0   U     0      0        0 br-487813c89507
192.168.144.0   0.0.0.0         255.255.240.0   U     0      0        0 br-7bdcb68e56b9
192.168.160.0   0.0.0.0         255.255.240.0   U     0      0        0 br-cb8119d1f760
192.168.176.0   0.0.0.0         255.255.240.0   U     0      0        0 br-1b5b146c2bf5
192.168.192.0   0.0.0.0         255.255.240.0   U     0      0        0 br-e4b843e75057
192.168.208.0   0.0.0.0         255.255.240.0   U     0      0        0 br-f710b39ebac3
192.168.224.0   0.0.0.0         255.255.240.0   U     0      0        0 br-a75994298ed0
192.168.240.0   0.0.0.0         255.255.240.0   U     0      0        0 br-b6131428cb15

Am I doing something wrong here in order to receive this error? Is it normal for docker to create a new network for every docker compose container? I’m still fairly new to using docker and Ubuntu, so I don’t know. some other posts I read said this error can be because of using a VPN, but I’m not using a VPN in a container, nor on the host.

No, but this is not what happens. If it did, none of your containers could communicate with eachother. Docker Compose creates a new network by default for each compose project. If you just test some compose project and don’t remove them, the network will stay there and eventually there will be no available network as all the IP ranges are used. If you have unused projects, remove them by running docker compose down in the project directory or remove the unused networks manually. You can also run docker network prune if the project directories are allready removed and want to remove all unused networks if the containers were removed as well.

If you really need lots of Docker compose projects, you have to customize the default address pool.

Quote from the example daemon.json:

  "default-address-pools": [
    {
      "base": "172.30.0.0/16",
      "size": 24
    },
    {
      "base": "172.31.0.0/16",
      "size": 24
    }
  ],

That would create two pools. One pool defines IP range of the pool with the network ip and the mask size of each network that can be created in the pool automatically. In the example it means the first pool can start with 172.30.0.0 and end with 172.30.255.255 and the second pool can start with 172.31.0.0 and end with 172.31.255.255. Since the size is 24, it means the first network in the first pool would be “172.30.1.0/24”, the second network would be “172.30.2.0/24” and so on. The default IP range is wide and allows roughly 65536 ip addresses in a single compose network, but the docker networks wer not created for compose specifically and you could need a large network in a large system where every container is on the same network. So it is just a very big network range that would be hard to run out of.

The best if you know exactly how many container you need in a compose project and configure the default network in that project to use a specific subnet like this:

networks:
  default:
    ipam:
      driver: default
      config:
        - subnet: 172.42.12.0/29
          gateway: 172.42.12.1

services:
  web:
    image: httpd:2.4

This allows 8 IP addresses in the subnet, but the first is the network IP, the second is the gateway, the last is the broadcast ip, so you have 8-3 = 5 free IP addresses for containers.

Your next compose project could be

networks:
  default:
    ipam:
      driver: default
      config:
        - subnet: 172.42.12.8/29
          gateway: 172.42.12.9

services:
  web:
    image: httpd:2.4

so now your project can use container IP addresses from 172.42.12.10 to 172.42.12.14.

I used 172.42.12 as an example, but it can be anything from the private ip ranges:

2 Likes

That’s exactly what happened! And I had to allow them to communicate by allowing each container through the firewall.

I’ll go through all of this when I wake up. I really appreciate you taking the time to answer questions.

The only way I can imagine this if you put only one service in every compose project or you defined a network for each service. What is your compose version? That is more relevant than the Docker version since Compose will create the networks.

Docker Compose Version: v2.24.1

Yes, I put one docker-compose.yml per folder in the /home directory. Unless a database was required, I only specified one service per docker-compose.yml file. Am I supposed to put more than one service in a docker-compose.yml file?

I’m using Ubuntu and I had to create the daemon.json file as it’s not present. And I used the example daemon.json file from this docker webpage Daemon Configuration file

And after a reboot of the system Docker would not start. So I deleted the /etc/docker/daemon.json file and then started docker.

I read that if you duplicate “flags” in the daemon.json file docker won’t start. But I’m unclear on what to leave out from the example given on the docker webpage.

I recommend reading the documentation

This is the very first sentence (after the warning)

Docker Compose is a tool for defining and running multi-container applications

It is to help you run multiple containers and allow them to communicate with eachother. If you need containers in different compose projects to communicate, you create a network manually using the docker command and define it in the compose file as external.

I didn’t share a complete config file. That must be a valid json.

Thanks for the reply and information.

Should I just put the information you shared in the daemon.json file and nothing else?

This is the file content I used

I don’t know if that example file is a working one. The data-root is empty for example. The system logs would show you what went wrong, but you can just use what I shared, except, you need to insert it in a valid json.

That is a complete file you can try:

{
  "default-address-pools": [
    {
      "base": "172.30.0.0/16",
      "size": 24
    },
    {
      "base": "172.31.0.0/16",
      "size": 24
    }
  ]
}
1 Like

Thanks for the reply.

Unfortunately, that didn’t work either. I’ll have to look at the logs and figure out why, but thank you for your time.

Edit: Sorry to bother you again, the only thing i can see in the logs, is this:

... failed to start daemon: Error initializing network controller: error creating default "bridge" network: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network

But the rest referring to docker looks like this: See screenshot

It won’t work if you don’t delete the networks that already reserved all the available subnets.

1 Like

Thanks.

I have success. Now the only thing I need to know in relation to this comment is how do I allow for 12 ip addresses for docker compose project. It has 9 containers. You’ve shown me how to make 8, but how would I make more IPs available? Thanks again.

I figured it out with the help of ChatGPT


networks:
  default:
    ipam:
      driver: default
      config:
        - subnet: 172.42.12.0/28
          gateway: 172.42.12.1

services:
  web:
    image: httpd:2.4

You already figured it out, but this subnet mask table could be useful too

1 Like