docker / cli

The Docker CLI
Apache License 2.0
4.88k stars 1.92k forks source link

can't remove networks #4558

Open skiffer-git opened 1 year ago

skiffer-git commented 1 year ago

Description

I want to remove three networks 172.28.0.1, 172.20.0.1, 172.19.0.1, but they cannot be found using 'docker network ls', and 172.28.0.1 is displayed twice.

root@VM-0-9-ubuntu:/data/openim/openim-docker# ifconfig
br-060f06276afb: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.28.0.1 netmask 255.255.0.0 broadcast 172.28.255.255
inet6 fe80::42:deff:fee2:31fc prefixlen 64 scopeid 0x20
ether 02:42🇩🇪e2:31:fc txqueuelen 0 (Ethernet)
RX packets 7 bytes 392 (392.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8 bytes 968 (968.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

br-44e4088c44fa: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.20.0.1 netmask 255.255.0.0 broadcast 172.20.255.255
inet6 fe80::42:b1ff:fe9f:99e0 prefixlen 64 scopeid 0x20
ether 02:42:b1:9f:99:e0 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 7 bytes 826 (826.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

br-5ad852a3ae66: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.19.0.1 netmask 255.255.0.0 broadcast 172.19.255.255
ether 02:42:b1:f3:29:d0 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

br-d1b3aac5521e: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.28.0.1 netmask 255.255.0.0 broadcast 172.28.255.255
inet6 fe80::42:2bff:febe:cfb8 prefixlen 64 scopeid 0x20
ether 02:42:2b:be:cf:b8 txqueuelen 0 (Ethernet)
RX packets 38 bytes 3076 (3.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 43 bytes 15757 (15.7 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:92:4e:22:76 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.0.9 netmask 255.255.252.0 broadcast 10.0.3.255
inet6 fe80::5054:ff:feba:2d9d prefixlen 64 scopeid 0x20
ether 52:54:00:ba:2d:9d txqueuelen 1000 (Ethernet)
RX packets 6091614 bytes 6741633723 (6.7 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2017927 bytes 492103886 (492.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 981548 bytes 92937288 (92.9 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 981548 bytes 92937288 (92.9 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

$ docker network ls
NETWORK ID NAME DRIVER SCOPE
45338a6d14b3 bridge bridge local
d74bd80fa9ee host host local
aa7c1e759469 none null local

$ root@VM-0-9-ubuntu:/data/openim/openim-docker# docker inspect 45338a6d14b3
[
   {
      "Name":"bridge",
      "Id":"45338a6d14b36e9963220d38cdbf844051565a83d0a6ebbc6ddcbb5722d00c3f",
      "Created":"2023-09-08T16:08:00.243341073+08:00",
      "Scope":"local",
      "Driver":"bridge",
      "EnableIPv6":false,
      "IPAM":{
         "Driver":"default",
         "Options":null,
         "Config":[
            {
               "Subnet":"172.17.0.0/16",
               "Gateway":"172.17.0.1"
            }
         ]
      },
      "Internal":false,
      "Attachable":false,
      "Ingress":false,
      "ConfigFrom":{
         "Network":""
      },
      "ConfigOnly":false,
      "Containers":{},
      "Options":{
         "com.docker.network.bridge.default_bridge":"true",
         "com.docker.network.bridge.enable_icc":"true",
         "com.docker.network.bridge.enable_ip_masquerade":"true",
         "com.docker.network.bridge.host_binding_ipv4":"0.0.0.0",
         "com.docker.network.bridge.name":"docker0",
         "com.docker.network.driver.mtu":"1500"
      },
      "Labels":{}
   }
]

root@VM-0-9-ubuntu:/data/openim/openim-docker# docker inspect d74bd80fa9ee
[
   {
      "Name":"host",
      "Id":"d74bd80fa9eec9972b288b1380a02de20be064a015bffca404d0fcb80c929621",
      "Created":"2023-09-08T16:08:00.206961596+08:00",
      "Scope":"local",
      "Driver":"host",
      "EnableIPv6":false,
      "IPAM":{
         "Driver":"default",
         "Options":null,
         "Config":[]
      },
      "Internal":false,
      "Attachable":false,
      "Ingress":false,
      "ConfigFrom":{
         "Network":""
      },
      "ConfigOnly":false,
      "Containers":{},
      "Options":{},
      "Labels":{}
   }
]

root@VM-0-9-ubuntu:/data/openim/openim-docker# docker inspect aa7c1e759469
[
   {
      "Name":"none",
      "Id":"aa7c1e759469ddbc082ba7a70a94fbd8d8a3c5f4b22044ba8139de0252c91b35",
      "Created":"2023-09-08T16:08:00.192821711+08:00",
      "Scope":"local",
      "Driver":"null",
      "EnableIPv6":false,
      "IPAM":{
         "Driver":"default",
         "Options":null,
         "Config":[]
      },
      "Internal":false,
      "Attachable":false,
      "Ingress":false,
      "ConfigFrom":{
         "Network":""
      },
      "ConfigOnly":false,
      "Containers":{},
      "Options":{},
      "Labels":{}
   }
]

Reproduce

only in my machine

Expected behavior

No response

docker version

root@VM-0-9-ubuntu:/data/openim/openim-docker# docker version
Client: Docker Engine - Community
 Version:           24.0.6
 API version:       1.43
 Go version:        go1.20.7
 Git commit:        ed223bc
 Built:             Mon Sep  4 12:31:44 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.6
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.7
  Git commit:       1a79695
  Built:            Mon Sep  4 12:31:44 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.22
  GitCommit:        8165feabfdfe38c65b599c4993d227328c231fca
 runc:
  Version:          1.1.8
  GitCommit:        v1.1.8-0-g82f18fe
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

root@VM-0-9-ubuntu:/home/ubuntu# docker info
Client: Docker Engine - Community
 Version:    24.0.6
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.21.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 13
 Server Version: 24.0.6
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8165feabfdfe38c65b599c4993d227328c231fca
 runc version: v1.1.8-0-g82f18fe
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.15.0-76-generic
 Operating System: Ubuntu 22.04 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.32GiB
 Name: VM-0-9-ubuntu
 ID: 81d7b242-36c3-4fab-8bdd-ff5f92e9b815
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional Info

No response

thaJeztah commented 1 year ago

That looks odd indeed; was there a specific situation that led to this issue? Mostly considering things like;

skiffer-git commented 1 year ago
version: '3'

networks:
  server:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: '${DOCKER_BRIDGE_SUBNET}'
          gateway: '${DOCKER_BRIDGE_GATEWAY}'

services:
  mysql:
    image: mysql:5.7
    ports:
      - "${MYSQL_PORT}:3306"
    container_name: mysql
    volumes:
      - "${DATA_DIR}/components/mysql/data:/var/lib/mysql"
      - "/etc/localtime:/etc/localtime"
    environment:
      MYSQL_ROOT_PASSWORD: "${MYSQL_PASSWORD}"
    restart: always
    networks:
      server:
        ipv4_address: ${MYSQL_NETWORK_ADDRESS}

I just use docker compose down or up -d, using the above yml file.

  1. Did you have failures when creating new networks (thinking if it possibly created the network "partially", but because of that didn't clean up) It's possible, but I am not sure. Is there any way I can clean up this network?It could be caused by upgrading the Docker version. Previously, I used docker-compose, but after upgrading Docker, I directly used docker compose.

  2. Did you change any daemon settings at some point (e.g. did you configure --default-address-pool or similar options)? No

3,. Did you manually remove state (e.g. clean /var/lib/docker) No

We are working on an open-source Instant Messaging (https://github.com/OpenIMSDK) project, which involves a lot of components, making the deployment complicated. Therefore, this issue is quite important for us

thaJeztah commented 1 year ago

@akerouanton any ideas?

akerouanton commented 1 year ago

Nope, no ideas.

only in my machine

Does that mean you can consistently reproduce this on your machine, but not other people in your team/company? Does they reappear when you reboot your VM?

Is there any way I can clean up this network?

Yes, you can delete them with:

$ sudo ip link del br-060f06276afb
$ sudo ip link del br-44e4088c44fa
$ sudo ip link del br-5ad852a3ae66
$ sudo ip link del br-d1b3aac5521e

It could be caused by upgrading the Docker version.

What version were you using?