Docker Can Create Only 31 Networks per Machine

I have just learned that in Docker there is a limit of 31 networks for default network driver on a single machine:

docker-black

This is due to the fact that it uses hardcoded list of broad network ranges – 172.17-31.x.x/16 and 192.168.x.x/20 – for bridge network driver. Look into ipamutils and allocator for more details. For overlay network driver 64K networks can be created.

There seems to be no solution to circumvent this limitation apart from manually specifying subnet ranges for each created network – see Docker network create subnet option and Docker Compose network configuration reference. In Puffin, which needs to create a separate network for each application, I implemented a simple address allocator.

6 thoughts on “Docker Can Create Only 31 Networks per Machine

  1. You can create more than 31 networks by controlling the subnet to be used by the docker network.

    Try this:

    for net in {1..50}; do docker network create -d bridge –subnet=172.18.${net}.0/24 net${net} ; done

  2. Yes, that’s what I mention in the last paragraph:

    > There seems to be no solution to circumvent this limitation apart from manually specifying subnet ranges for each created network – see Docker network create subnet option …

  3. Hi,
    I have 1000 containers on a machine and I want to create a network per container. So I need to create 1000 networks. Is it possible?

  4. Yeah, I think so, why wouldn’t it be? Also keep in mind that you don’t have to create a separate network for each container if you don’t need to.

  5. But you said docker can’t create more than 31 networks and I have 1000 containers so I need to create 1000 networks.

  6. If you need to have 1000 containers and each of them needs to have a separate network, then it’s possible by using custom subnet ranges as described in the last paragraph of this short article. For a Python example implementation see the last link in the article.

Leave a Reply

Your email address will not be published.