Docker "ERROR: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network"
Solution 1
Following Peter Hauge's comment, upon running docker network ls
I saw (among other lines) the following:
NETWORK ID NAME DRIVER SCOPE
dc6a83d13f44 bridge bridge local
ea98225c7754 docker_gwbridge bridge local
107dcd8aa889 host host local
The line with NAME
and DRIVER
as both host
seems to be what he is referring to with "networks already created on your host". So, following https://gist.github.com/bastman/5b57ddb3c11942094f8d0a97d461b430, I ran the command
docker network rm $(docker network ls | grep "bridge" | awk '/ / { print $1 }')
Now docker-compose up
works (although newnym.py
produces an error).
Solution 2
I've seen it suggested docker may be at its maximum of created networks. The command docker network prune
can be used to remove all networks not used by at least one container.
My issue ended up being, as Robert commented about: an issue with openvpn service openvpn stop
'solved' the problem.
Solution 3
I ran into this problem because I had OpenVPN running. As soon as I killed OpenVPN, docker-compose up
fired right up, and the error disappeared.
Solution 4
I ran in this problem with OpenVPN working as well and I've found a solution where you should NOT stop/start OpenVPN server.
Idea that You should specify what exactly subnet you want to use. In docker-compose.yml
write:
networks:
default:
driver: bridge
ipam:
config:
- subnet: 172.16.57.0/24
That's it. Now, default
network will be used and if your VPN did not assign you something from 172.16.57.*
subnet, you're fine.
Solution 5
I have the same problem. I ran docker system prune -a --volumes
, docker network prune
, but neither helped me.
I use a VPN, I turned off the VPN and, after it docker started normal and was able to create a network. After that, you can enable VPN again.
Related videos on Youtube

Comments
-
Kurt Peek over 1 year
I have a directory
apkmirror-scraper-compose
with the following structure:. ├── docker-compose.yml ├── privoxy │ ├── config │ └── Dockerfile ├── scraper │ ├── Dockerfile │ ├── newnym.py │ └── requirements.txt └── tor └── Dockerfile
I'm trying to run the following
docker-compose.yml
:version: '3' services: privoxy: build: ./privoxy ports: - "8118:8118" links: - tor tor: build: context: ./tor args: password: "" ports: - "9050:9050" - "9051:9051" scraper: build: ./scraper links: - tor - privoxy
where the
Dockerfile
fortor
isFROM alpine:latest EXPOSE 9050 9051 ARG password RUN apk --update add tor RUN echo "ControlPort 9051" >> /etc/tor/torrc RUN echo "HashedControlPassword $(tor --quiet --hash-password $password)" >> /etc/tor/torrc CMD ["tor"]
that for
privoxy
isFROM alpine:latest EXPOSE 8118 RUN apk --update add privoxy COPY config /etc/privoxy/config CMD ["privoxy", "--no-daemon"]
where
config
consists of the two lineslisten-address 0.0.0.0:8118 forward-socks5 / tor:9050 .
and the
Dockerfile
forscraper
isFROM python:2.7-alpine ADD . /scraper WORKDIR /scraper RUN pip install -r requirements.txt CMD ["python", "newnym.py"]
where
requirements.txt
contains the single linerequests
. Finally, the programnewnym.py
is designed to simply test whether changing the IP address using Tor is working:from time import sleep, time import requests as req import telnetlib def get_ip(): IPECHO_ENDPOINT = 'http://ipecho.net/plain' HTTP_PROXY = 'http://privoxy:8118' return req.get(IPECHO_ENDPOINT, proxies={'http': HTTP_PROXY}).text def request_ip_change(): tn = telnetlib.Telnet('tor', 9051) tn.read_until("Escape character is '^]'.", 2) tn.write('AUTHENTICATE ""\r\n') tn.read_until("250 OK", 2) tn.write("signal NEWNYM\r\n") tn.read_until("250 OK", 2) tn.write("quit\r\n") tn.close() if __name__ == '__main__': dts = [] try: while True: ip = get_ip() t0 = time() request_ip_change() while True: new_ip = get_ip() if new_ip == ip: sleep(1) else: break dt = time() - t0 dts.append(dt) print("{} -> {} in ~{}s".format(ip, new_ip, int(dt))) except KeyboardInterrupt: print("Stopping...") print("Average: {}".format(sum(dts) / len(dts)))
The
docker-compose build
builds successfully, but if I trydocker-compose up
, I get the following error message:Creating network "apkmirrorscrapercompose_default" with the default driver ERROR: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network
I tried searching for help on this error message, but couldn't find any. What is causing this error?
-
Robert about 6 yearsDo you have a VPN connected? Also, have you tried restarting your compueter? (I am googling) github.com/moby/moby/issues/30295
-
Jinna Balu almost 4 years
docker network prune
. This will resolve your issue
-
-
jb. almost 6 yearsIf you need to run docker alongside vpn here is possible solution: stackoverflow.com/q/45692255/7918.
-
berkes over 5 yearsSame here with another VPN provider (expressvpn).
-
Nicolai about 5 yearsThe same problem with running OpenVPN
-
David Ficociello about 5 yearsSo I had the same issue and I'm wondering why this is happening. Why does Docker networking get confused when connected to a VPN.
-
Liviu Ilea almost 5 yearsOpenVPN Service was the issue for me.
-
Sweet Chilly Philly almost 5 yearsTo add to the above answer, if you get any issue like this pruning the system can really help.
Docker system prune
can also be a fix, but please be careful, this can remove your DB, only use this if you don't care for you DB, or if your DB container is running then this command is safe as it only prunes things not being used by at least one container. -
Attila Szeremi over 4 yearsI would never have guessed. Thanks so much!
-
Nicolas over 4 yearsI had the same problem with Private Internet Access
-
XtraSimplicity over 4 yearsMy VPN connection was on the same subnet as the one docker was trying to use. Disconnecting solved the problem for me. :)
-
Douglas Liu over 4 yearsI've added routes rather than
redirect-gateway def1
to get around the issue without killing my openvpn service. -
iBug almost 4 yearsThis is great! My server box can't stand without OpenVPN so advices on (even temporarily) disabling VPN are all nonsense to me.
-
michnovka almost 4 yearsthis should be the accepted answer, as simply killing VPN is stupid
-
Rodrigo Hernández Mota over 3 yearsSame problem when using PIA VPN.
-
dstromberg over 3 yearsIsn't 172.177.57.0/24 a routed newtork? If so, it could cause problems contacting a limited number of hosts on the internet.
-
Arenim over 3 yearsyep, a glitch here. Would be better to use one from
172.16.*.*
subnet -
Damien Roche over 3 yearsImagine a life where our tools give us useful debugging information.
-
IMB over 3 yearsI've no VPN running but
docker-compose down
fixed it for me -
Sma Ma over 3 yearssame problem because because I had VPN called
globalprotect
from paloaltonetworks running. As soon as I disconnect VPN the error disappeared. After the docker network is created you can enable your VPN again. -
lucidyan over 3 yearsI don't think that using
172.177.57.*
is a good idea, because it not in the en.wikipedia.org/wiki/Private_network#Private_IPv4_addresses. Use addresses within this range. -
tephyr over 3 yearsThe specific command to switch from OpenVPN to the WireGuard protocol for NordVPN is
nordvpn set technology NordLynx
. It is not a separate product, and currently is only available on Linux & iOS. -
Jaza about 3 yearsThanks so much for this solution! I need to run
docker-compose
with NetScaler (nsgclient
on Ubuntu) VPN enabled, because various scripts in our docker images make requests to servers within our corporate network. This does the trick for me. -
chovy about 3 yearsis this a question or an answer?
-
Stefan van den Akker about 3 yearsMore a: my adventures in Docker-network land and how I stumbled onto something that stuck.
-
Abhay Maniyar about 3 yearsThis worked. I tried
docker network prune
but it didn't help then I noticed this answer. Disconnecting with vpn worked immediately. -
therobyouknow almost 3 yearssame problem with Speedify VPN v9.9.0.8564 on Ubuntu 20.04. I don't think I saw this issue on Ubuntu 18.04 whilst running Speedify though.
-
Tobias Ernst over 2 yearsThanks a lot for the answer. Restarting the docker service is required after making the changes to
/etc/docker/daemon.json
. -
Willian over 2 yearsThank you so much @Вячеслав Калякин! Turning Off VPN solved my case as well.
-
Benny64 over 2 yearsFor anyone who still has the issue after stopping VPN and running
docker network prune
, you may have to restart your PC. That solved it for me! -
Noman Ur Rehman about 2 yearsPerhaps add a bit more details to this answer as to what the problem is and how this command solves it. Otherwise, it seems to get lost in the scrollfest because it is very short :D
-
Steven Rosato about 2 yearsThank you for this! It worked perfectly and no additional installs were required for me, just running
nordvpn set technology NordLynx
did the trick. -
dexter2305 about 2 yearsThis should be marked as the answer instead of ``` docker network prune ``` or re-configuring the default bridge in the compose which are not scalable. In this case, pool can always be added.
-
Stephane almost 2 yearsFacing the same error message I soled it with the command:
docker network create -d bridge --subnet 172.16.57.0/24 roachnet
-
Maxime La-x almost 2 yearsSame with Cisco Anyconnect on Ubuntu
-
bonafernando almost 2 yearsConfirmed here. You saved me from starting running unknown commands.
-
Chang Zhao over 1 yearyes, it solved for me too, but how can we have openvpn running and still not get this error?
-
wlarcheveque over 1 yearI had the same problem having a NordVPN connection active. I disconnected from the VPN and reconnected after launching the docker containers.
-
Md Atiqul Haque over 1 yearAlso, solve for me after off the open vpn connection.