Reputation: 368
When I create a new network, docker creates it with an address like 172.255.255.255 (172.17.1.0, 172.18.1.0, etc). But this could conflict with external addresses, since all machines in my network has the same prefix (172.255.255.255)
Is there a way to configure a base subnet address to be used by docker at creation of new networks?
[Update] I'm creating and deleting networks automatically, so, I can't set the --subnet option (since I don't know what address are in use or not). I need that docker manages the pool of address dynamically, like it manages the ingress network (auto allocating and prune subnets). Actually, what I need is only customize the ingress base address!
Upvotes: 3
Views: 2564
Reputation: 2896
Docker 18.06 introduces the --default-address-pool
option. With it you can specify the address range that user defined networks will use by default instead of the standard 172.x
You can see the pull requests where the features has been implemented and discussed for more information: moby/29376, moby/36054, moby/36396,
You can set the parameter as a command line argument to the docker daemon:
--default-addr-pool
This flag specifies default subnet pools for global scope networks. Format example is
--default-addr-pool 30.30.0.0/16 --default-addr-pool 40.40.0.0/16
Or in /etc/docker/daemon.json
:
{
"default-address-pools": [
{"base":"172.80.0.0/16","size":24}
]
}
Upvotes: 5
Reputation: 488
The default network is named bridge. That is setup to use the 172 range.
What you need to do is create your own bridge network.
$ docker network create -d bridge my_bridge
(use the --ip-range option)
Then you can add a container to that network.
$ docker run -d --net=my_bridge --name db training/postgres
https://docs.docker.com/engine/tutorials/networkingcontainers/
Upvotes: 1