[Solved] docker Error: bridge docker0 failed: exchange full

Error reported: Bridge docker0 failed: exchange full

the default docker0 bridge only supports 1024 links. If it exceeds 1024, it will report bridge docker0 failed: exchange full

you can remove the restriction by creating another network bridge. When docker run creates a container, you specify our own network bridge. Of course, we only support 1024 network bridges. You can use this method to create unlimited network bridges as long as there is enough memory to create a docker container

1. View Bridge

[root@bj ~]# docker network ls
NETWORK ID     NAME      DRIVER    SCOPE
0c49b2d827f5   bridge    bridge    local
8ec28361848f   host      host      local
3b929af4064c   none      null      local

2. Create Bridge

[root@bj ~]# docker network create xinnet
[root@bj ~]# docker network ls
NETWORK ID     NAME      DRIVER    SCOPE
0c49b2d827f5   bridge    bridge    local
8ec28361848f   host      host      local
3b929af4064c   none      null      local
604ccc72661a   xinnet    bridge    local
[root@bj ~]# docker network inspect xinnet
[
    {
        "Name": "xinnet",
        "Id": "604ccc72661af52f0889bfea4664d70e899427418b1a9301d8a46e6ce95e46ee",
        "Created": "2021-12-08T13:50:43.973901095+08:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.19.0.0/16",
                    "Gateway": "172.19.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "e92f81a6fe11b6e2c82de38fbe4e06a9cfcdb1dcd1f64485e5b805e3714bd163": {
                "Name": "zabbix-agent-22000",
                "EndpointID": "b7ac1a57b2e91435c676a7b4203ab50237893a3714aff185d8cdac45b1251356",
                "MacAddress": "02:42:ac:13:00:02",
                "IPv4Address": "172.19.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]

3. Create container specified bridge – network

[root@bj ~]# docker run -m 100m --name zabbix-agent-22001 --network=xinnet -e HOSTNAME="TEST22001" -e ZBX_HOSTNAME="TEST22001" -e ZBX_SERVER_HOST="10.20.9.246" -p 22001:10050 -e ZBX_SERVER_PORT=10051 -d zabbix-agent:4.0.35 
[root@bj ~]# docker ps -a
CONTAINER ID   IMAGE                 COMMAND                  CREATED          STATUS          PORTS                      NAMES
e92f81a6fe11   zabbix-agent:4.0.35   "/usr/bin/tini -- /u…"   15 minutes ago   Up 15 minutes   0.0.0.0:22001->10050/tcp   zabbix-agent-22001

If – network is not specified, the created containers will be hung on docker0 by default, and the IP of docker0 interface on the local host will be used as the default gateway for all containers

Read More: