I have configured the default docker bridge dockerO
using the daemon.json
as follows:
{
"bip": "192.168.1.5/24",
"fixed-cidr": "192.168.1.5/25"
}
But my containers are not connecting to the bridge, I am not using any user-defined bridges.
$ docker network inspect bridge
[
{
"Name": "bridge",
"Id": "0af71606024f88dd7ef5f14b9298d2aff76a6e5016e8a67745ceb401820949cb",
"Created": "2019-12-31T09:56:41.626771723Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "192.168.1.5/24",
"IPRange": "192.168.1.0/25",
"Gateway": "192.168.1.5"
}
]
},
"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": {}
}
]
Also, my docker status shows the container ip in the default 172.xxx
range.
CGroup: /system.slice/docker.service
|-3243 /usr/bin/dockerd
|-3252 docker-containerd --config /var/run/docker/containerd/containerd.toml
|-3350 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9000 -container-ip 172.18.0.2 -container-port 9000
|-3363 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8500 -container-ip 172.18.0.2 -container-port 8100
|-3374 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 514 -container-ip 172.18.0.2 -container-port 514
|-3387 /usr/bin/docker-proxy -proto udp -host-ip 0.0.0.0 -host-port 514 -container-ip 172.18.0.2 -container-port 514
`-3395 docker-containerd-shim -namespace moby -workdir /var/lib/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/92e91d6994d0ea9d6f44cd2b3956397db5bc0942f202b79cf86439c10ba92f5f -add...
Do I need to change anything else for the containers to connect to this bridge?
My container was using another user-configured network. To change that I followed the below steps:
Disconnect docker containers connected to the network and remove the network.
docker network disconnect <network-name> <container> docker network rm <network-name>
Re-create the network with the desired subnet and gateway.
docker network create --subnet=192.168.1.0/24 --gateway=192.168.1.1 <network-name>
Connect the docker containers to the newly created network.
docker network connect <network-name> <container>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.