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 does it work? — the Art of Code Trace

What is Cloud PLM?

What is the cheapest VPS Hosting?

What is a Ruby developer? What is a Ruby developer?

“tail -f” in Windows PowerShell

Tezos Faucet. How to get free Tezos for Hangzhou test blockchain.

CKA, CKAD & CKS Exam Voucher Codes

Journal 44 — Player update in Unity, Press C to Collect Power Ups!

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

Advanced Monika alert queries: A guide to operators and helpers

Better static analysis with entity type storages in phpstan-drupal 1.10

How and why to use Git Submodules

How to implement a Docker Desktop alternative in macOS with Podman