I have a directory apkmirror-scraper-compose
with the following structure:
.
├── docker-compose.yml
├── privoxy
│ ├── config
│ └── Dockerfil
As other answers mentioned, Docker's default local bridge
network only supports 30 different networks (each one of them uniquely identifiable by their name). If you are not using them, then docker network prune
will do the trick.
However, you might be interested in establishing more than 30 containers, each with their own network. Were you interested in doing so then you would need to define an overlay
network. This is a bit more tricky but extremely well documented here.
EDIT (May 2020): Link has become unavailable, going through the docs there's not an exact replacement, but I would recommend starting from here.
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
.
I encoutered the same problem, the reason why is that you reached the max of networks:
do an : docker network ls
Choose one to remove using: docker network rm networkname_default
Killing the vpn is not needed.
This other comment about using a new network comes pretty close to the solution for me, and was working for a while, but I found a better way thanks to some talk over in another question
Create a network with:
docker network create your-network --subnet 172.24.24.0/24
Then, at the bottom of docker-compose.yaml, put this:
networks:
default:
external:
name: your-network
Done. No need to add networks to all container definitions etc. and you can re-use the network with other docker-compose files as well if you'd like.
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.
docker-compose down
If VPN is connected, then disconnect it and try again to up docker container:
docker-compose up -d container_name