问题原文
原帖链接 · jrtapsell · CC BY-SA 4.0
Due to problems with captive portals and the default Docker IP range I am trying to make Docker use the 198.18.0.0 range, instead of 172.17.0.0, which clashes with the captive portals used on the trains where I live.
Following the docs, I created /etc/docker/daemon.json, and put the following in it:
{
"bip":"198.18.0.0/16"
}
This worked for docker0, but it seems to not have affected any of the other networks, and using docker compose the first network created is 172.17.0.0, which recreates the clash.
What can I do to change the default subnet for all docker networks (preferably without having to state my custom IP range in every compose file)?
已采纳解答
原帖链接 · rNix · CC BY-SA 4.0
It is possible to redefine default range.
$ docker -v
Docker version 18.06.0-ce, build 0ffa825
Edit or create config file for docker daemon:
# nano /etc/docker/daemon.json
Add lines:
{
"default-address-pools":
[
{"base":"10.10.0.0/16","size":24}
]
}
Restart dockerd:
# service docker restart
Check the result:
$ docker network create foo
$ docker network inspect foo | grep Subnet
"Subnet": "10.10.1.0/24"
It works for docker-compose too. More info here https://github.com/moby/moby/pull/29376 (merged)
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
