Docker for Mac network problems and solutions

2 min readNov 8, 2021


It can be said that it is very convenient for docker for mac to run the local development environment.

But Docker for Mac has always had a problem since it was born, that is, docker0 cannot be seen on the host machine, and the network where the container is located cannot be accessed, which means that the IP address assigned by Docker to the Container cannot be pinged. Regarding this issue, the official document has a description:Known limitations, use cases, and workarounds

For the Container started by docker run, the corresponding service port is usually mapped through the -p parameter, and it is generally not encountered in the case of directly accessing the container IP.

But when we run multiple microservices in docker and want to debug locally, it can’t be achieved on Mac.


Use docker-connector

First install docker-connector on the Mac side through brew

brew install wenjunxiao/brew/docker-connector

Then execute the following command to add all bridge networks of docker to the route

docker network ls --filter driver=bridge --format "{{.ID}}" | xargs docker network inspect --format "route {{range .IPAM.Config}}{{.Subnet}}{{end}}" >> /usr/local/etc/docker-connector.conf

You can also manually modify the route in the /usr/local/etc/docker-connector.conf file, the format is


The routing subnet determines which containers you can access

After the configuration is complete, start the service directly (sudo is required, the routing configuration can still be modified after it is started, and it will take effect immediately without restarting the service)

sudo brew services start docker-connector

Then use the following command to run wenjunxiao/mac-docker-connector on the docker side, you need to use the host network and allow NET_ADMIN

docker run -it -d --restart always --net host --cap-add NET_ADMIN --name connector wenjunxiao/mac-docker-connector

Choose a container IP to test, my test IP is, and start an HTTP service in the corresponding container

$ python -m SimpleHTTPServer 8080
Serving HTTP on port 8080 ...

Ping and access http services directly on the host machine

$ ping
PING ( 56 data bytes
64 bytes from icmp_seq=0 ttl=63 time=0.837 ms
64 bytes from icmp_seq=1 ttl=63 time=1.689 ms
64 bytes from icmp_seq=2 ttl=63 time=2.793 ms
64 bytes from icmp_seq=3 ttl=63 time=2.333 ms

Re-verify HTTP service

$ curl -si -w "%{http_code}" -o /dev/null200




spark kafak flink develop