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.
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.
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.
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).
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.
Add
version: '3.7'
services:
web:
...
network_mode: bridge
Read about network_mode
in the
documentation.
Disclaimer: I am not very knowledgeable about Docker networking, but this did the trick for me. YMMV.
When I ran docker run my-image
the networking gave me no problems, but when
I converted this command to a docker-compose.yml
file, I got the same error
as the OP.
I read Arenim's answer and some other stuff on the internet that suggested to re-use an existing network.
You can find existing networks like this:
# docker network ls
NETWORK ID NAME DRIVER SCOPE
ca0415dfa442 bridge bridge local
78cbbda034dd host host local
709f13f4ce2d none null local
I wanted to reuse the default bridge
network, so I added
services:
web:
...
networks:
default:
external:
name: bridge
to the the root of my docker-compose.yml
(so not inside one of my
services
, but at the root indentation).
I now got the following error:
ERROR: for your-container network-scoped alias is supported only for containers in user defined networks
This led met to this Docker Github
issue, that plainly stated
that I should add the network_mode
object to my docker-compose
:
version: '3.7'
services:
web:
...
network_mode: bridge
This was tested on Docker version 18.09.8
, docker-compose
version 1.24.1
and the compose file format 3.7
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With