Docker “ERROR: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network”

前端 未结 19 598
别那么骄傲
别那么骄傲 2020-12-12 10:48

I have a directory apkmirror-scraper-compose with the following structure:

.
├── docker-compose.yml
├── privoxy
│   ├── config
│   └── Dockerfil         


        
相关标签:
19条回答
  • 2020-12-12 11:02

    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.

    0 讨论(0)
  • 2020-12-12 11:07

    TL;DR

    Add

    version: '3.7'
    services:
      web:
        ...
        network_mode: bridge
    

    Read about network_mode in the documentation.

    Long version

    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.

    0 讨论(0)
  • 2020-12-12 11:07

    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

    0 讨论(0)
  • 2020-12-12 11:08

    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.

    0 讨论(0)
  • 2020-12-12 11:09

    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.

    0 讨论(0)
  • 2020-12-12 11:09
    1. Check if any other container is running, If yes, do: docker-compose down
    2. If VPN is connected, then disconnect it and try again to up docker container:

      docker-compose up -d container_name
      
    0 讨论(0)
提交回复
热议问题