Docker for Mac network problems and solutions

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How To Build A Multiplayer Browser Game (Part 2)

Like Regular LINQ, but Faster and Without Allocations: Is It Possible?

Controlling Light by Telegram from Bot with Adafruit_IO

Microsoft Intune — Win32App / .intunewin packages — Lessons learned

Spring Data JPA: A Generic Specification Query Language


Managed Kubernetes Cluster (HA) for Side Projects

Register, login, and logout, boilerplate. Written in Vue.JS, and Python as API.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


spark kafak flink develop

More from Medium

Customise your zsh terminal and prompt in MacOS!

GitHub Actions: Passing Boolean input variables to reusable workflow_call

Integrate Monika with Google Chat using Webhook

Gitlab SSH Config Host File, Allowing Multiple Account SSH Access