原 创建或启动容器报错Error response from daemon network bridge is ambiguous (2 matches found on name)及删除多余的bridge时报错Error response from daemon bridge is a pre-defined network and cannot be removed
报错
启动容器报错:Error response from daemon: network bridge is ambiguous (2 matches found on name)
1 2 3 4 5 6 7 8 9 10 11 12 | [root@lhrxxt ~]# docker run --name lhrpg10 -h lhrpg10 -d -p 54323:5432 -e POSTGRES_PASSWORD=lhr -e TZ=Asia/Shanghai -e POSTGRES_INITDB_ARGS="--data-checksums" postgres:10.21 docker: Error response from daemon: Conflict. The container name "/lhrpg10" is already in use by container "81eea8e25d52a66e14874355265c55bbcfbddd124eff43c70d529208a9be55e3". You have to remove (or rename) that container to be able to reuse that name. See 'docker run --help'. [root@lhrxxt ~]# [root@lhrxxt ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES [root@lhrxxt ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 81eea8e25d52 postgres:10.21 "docker-entrypoint.s…" 33 seconds ago Created lhrpg10 [root@lhrxxt ~]# docker start lhrpg10 Error response from daemon: network bridge is ambiguous (2 matches found on name) Error: failed to start containers: lhrpg10 |
分析
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | [root@lhrxxt ~]# docker network ls NETWORK ID NAME DRIVER SCOPE 6e25af68f735 bridge bridge local c0daf0a97d3a bridge bridge local 0b047fd33c19 host host local 9383bec8f27a none null local [root@lhrxxt ~]# docker network inspect 6e25af68f735 [ { "Name": "bridge", "Id": "6e25af68f735fa184b27c0a2c550975f1c70f7c58afda477d52f31b0b2b39f7f", "Created": "2024-03-01T08:51:51.304761693+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@lhrxxt ~]# docker network inspect c0daf0a97d3a [ { "Name": "bridge", "Id": "c0daf0a97d3a914fbbbc7ea53685420e628146bb3daabe4df582dfece0b1b722", "Created": "2024-02-23T19:58:53.112238406+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@lhrxxt ~]# docker network rm c0daf0a97d3a Error response from daemon: bridge is a pre-defined network and cannot be removed [root@lhrxxt ~]# docker network rm c0daf0a97d3a -f Error response from daemon: bridge is a pre-defined network and cannot be removed [root@lhrxxt ~]# [root@lhrxxt ~]# systemctl restart docker [root@lhrxxt ~]# docker network ls NETWORK ID NAME DRIVER SCOPE 12c25c27ba51 bridge bridge local c0daf0a97d3a bridge bridge local 0b047fd33c19 host host local 9383bec8f27a none null local [root@lhrxxt ~]# [root@lhrxxt ~]# [root@lhrxxt ~]# docker network rm 12c25c27ba51 --force Error response from daemon: bridge is a pre-defined network and cannot be removed |
故障处理
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | [root@lhrxxt ~]# cd /var/lib/docker/network/files/ [root@lhrxxt files]# ll total 56 -rw-r--r-- 1 root root 65536 Mar 1 09:13 local-kv.db [root@lhrxxt files]# systemctl stop docker Warning: Stopping docker.service, but it can still be activated by: docker.socket [root@lhrxxt files]# ll total 56 -rw-r--r-- 1 root root 65536 Mar 1 09:13 local-kv.db [root@lhrxxt files]# rm -rf local-kv.db [root@lhrxxt files]# systemctl start docker [root@lhrxxt files]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES [root@lhrxxt files]# ll total 32 -rw-r--r-- 1 root root 65536 Mar 1 09:21 local-kv.db [root@lhrxxt files]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 81eea8e25d52 postgres:10.21 "docker-entrypoint.s…" 18 minutes ago Created lhrpg10 [root@lhrxxt files]# docker start lhrpg10 lhrpg10 [root@lhrxxt files]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 81eea8e25d52 postgres:10.21 "docker-entrypoint.s…" 18 minutes ago Up 1 second 0.0.0.0:54323->5432/tcp, :::54323->5432/tcp lhrpg10 [root@lhrxxt files]# [root@lhrxxt files]# docker network ls NETWORK ID NAME DRIVER SCOPE 245d912491a9 bridge bridge local e1aae008d107 host host local ad4d136ea92f none null local [root@lhrxxt files]# |
总结
1、若是非bridge网卡,则可以直接删除