Bridge Network Configuration With Colima and Docker
Written on
This issue caused me way more time than I would like to admit so I'm writing this blog posting in hopes it will help someone else and save them some time.
I'm in the process of making the switch from developing with vim directly on Linux servers to using VS Code and dev containers. I'm running on MacOS using homebrew Docker and colima. This all worked well with default settings until I had to communicate to devices on the LAN. I'm writing a web service that needs to communicate with servers on the LAN networks in 172.17. and by default colima uses a 172.17 bridge network:
% docker network inspect bridge
[
{
"Name": "bridge",
"Id": "9781664d924ce946f9080bb58c52f0511e7bc752782c2729446261ea26c9d891",
"Created": "2025-04-06T04:07:57.135348838-04: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": {}
}
]
Because my dev servers are in 172.17 routing to them failed. I started by trying to reconfigure the docker network by changing the network in ~/.docker/daemon.json
but that did not change the docker bridge network in the docker container running in colima.
~/.docker/daemon.json
{
"bip": "192.168.1.1/24",
"default-address-pools": [
{
"base": "192.168.100.0/24",
"size": 27
}
],
"dns": [
"1.1.1.1",
]
}
NOTE: You're probably going to want to set your local DNS servers here in case they're running internal views to publish non routable IPs for internal servers.
This did reconfigure the colima network and the IP address of the colima VM was in 192.168 but the docker containers were still using 172.17.0.0/16
. I attempted setting up custom networks in my docker-compose.yml
which did not work either.
SOLUTION: Change Configuration In ~/.colima/default/colima.yaml
You set the docker daemon configuration running in colima in ~/.colima/default/colima.yaml
. You can edit that file when starting colima and configuring docker there.
colima start --edit
and set docker:
as follows:
# Colima default behaviour: buildkit enabled
# Default: {}
docker:
bip: 192.168.1.1/24
default-address-pools:
- base: 192.168.200.0/24
size: 27
dns:
- 1.1.1.1
Now the docker bridge network running in colima should be reconfigured.
% docker inspect network bridge
[
{
"Name": "bridge",
"Id": "dcfb3c3bcee2944747306f1c3e18e2533db04fc37d49b4c9bf18eec7da8f374b",
"Created": "2025-04-06T04:47:32.991803255-04:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "192.168.1.0/24",
"Gateway": "192.168.1.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": {}
}
]