0

我在 Fedora 33 上使用 Docker 20.10.7:

$ uname -r
5.12.8-200.fc33.x86_64
$ docker -v
Docker version 20.10.7, build f0df350

尝试创建新的 docker 网络时,出现以下错误:

$ docker network create --subnet 172.18.128.0/17 si
Error response from daemon: cannot create network 87c3cae81d6e379b4fec55a671fc26e547debc218d16b9e762435b7aa6f9ca28 (br-87c3cae81d6e): conflicts with network 8247c1fe85afa51c174529086ad8bc58069e8aac336cc99239b2cce21311ecb9 (br-8247c1fe85af): networks have overlapping IPv4

尽管除了默认值之外似乎不存在任何 docker 网络:

$ docker network ls
NETWORK ID     NAME      DRIVER    SCOPE
93e55f691850   bridge    bridge    local
57062f01a833   host      host      local
3f81078d2755   none      null      local

似乎存在一些网桥。这些可能是已被删除的 docker 网络的残余:

$ brctl show
bridge name bridge id       STP enabled interfaces
br-0ccb5edb60fa     8000.02425e65824c   no      
br-0ebff3222c7d     8000.0242ad165003   no      
br-13b92f8a402d     8000.0242fd54405d   no      
br-3fe8819f1dab     8000.0242df196682   no      
br-62855eeb66b1     8000.024279b970d4   no      
br-64f88c232b42     8000.024294a697d3   no      
br-6cb52985982b     8000.0242fa683006   no      
br-7b91629f9dc5     8000.02429075dacd   no      
br-8247c1fe85af     8000.0242da4e1ba9   no      
br-9e6e08fae543     8000.0242a0c94c05   no      
br-b04024820e6b     8000.024251673cfb   no      
br-bb03dc88def2     8000.0242d550a519   no      
br-c3bfd0e7bfac     8000.02420fc70d06   no      
br-f446efca8607     8000.02423c5f7dff   no      
br-fc4085566463     8000.0242c5a5a9ed   no      
docker0     8000.0242090fcff7   no

所以我的想法是删除这些桥,认为创建新的 docker 网络应该在此之后工作:

$ sudo ip link del br-0ccb5edb60fa # do this for all bridges
$ brctl show
bridge name bridge id       STP enabled interfaces
docker0     8000.0242090fcff7   no

但唉,错误仍然存​​在:

$ docker network create --subnet 172.18.128.0/17 si
Error response from daemon: cannot create network 60b9a9c6f1b032cf54ac799e5b8f2a96b1d55a05492e5357ffb6b002f10a27de (br-60b9a9c6f1b0): conflicts with network fc4085566463d57a641dbb3f5bba4888dbdf3908868f30d4e0c46edf19c001e4 (br-fc4085566463): networks have overlapping IPv4

我认为重新启动 docker 服务可能会解决问题

$ sudo systemctl restart docker

但是重启docker服务后,网桥又出现了!

$ brctl show
bridge name bridge id       STP enabled interfaces
br-0ccb5edb60fa     8000.0242ba61c513   no      
br-0ebff3222c7d     8000.0242ae82887a   no      
br-13b92f8a402d     8000.02421fa70d86   no      
br-3fe8819f1dab     8000.0242a7c0d3cd   no      
br-62855eeb66b1     8000.02423b35c43d   no      
br-64f88c232b42     8000.0242e3235138   no      
br-6cb52985982b     8000.024264333192   no      
br-7b91629f9dc5     8000.02420c574876   no      
br-8247c1fe85af     8000.02423b3845ee   no      
br-9e6e08fae543     8000.024285a4da86   no      
br-b04024820e6b     8000.02425a16a19f   no      
br-bb03dc88def2     8000.02422c2da231   no      
br-c3bfd0e7bfac     8000.024250df5e93   no      
br-f446efca8607     8000.024234091377   no      
br-fc4085566463     8000.0242eda476ce   no      
docker0     8000.0242090fcff7   no

我尝试过的其他事情,但没有帮助:

$ docker network prune -f
$ docker system prune -f
# tried the following commands for all existing bridges
$ nmcli connection delete br-0ccb5edb60fa
$ sudo brctl delbr br-0ccb5edb60fa
$ sudo firewall-cmd --zone=docker --remove-interface=br-0ccb5edb60fa --permanent
Warning: NOT_ENABLED: br-0ccb5edb60fa
success

什么可能阻止我可靠地删除网桥?

4

1 回答 1

0

我弄清楚为什么 docker 一直在重建 brigdes。它们似乎存储在/var/lib/docker/network/files/local-kv.db二进制文件 (BoltDB) 中,这解释了为什么我没有用grep.

删除文件并重新启动 docker 解决了我的问题。以下命令(在 中执行zsh,其他 shell 可能不同)删除所有网桥、上述文件并重新启动 docker 服务。之后,我可以毫无错误地创建 docker 网络。

while read; do
  if [ ! -z "$REPLY" ]; then
    sudo ip link del $REPLY
  fi
done <<<"$(brctl show | grep '^br-' | awk '{print $1}')"
sudo rm /var/lib/docker/network/files/local-kv.db
sudo systemctl restart docker
于 2021-06-10T08:28:10.373 回答