参考地址:https://github.com/docker/for-mac/issues/2670
To enable the proxy first shutdown the app, then enable the experimental SOCKS
server on port 8888: (this requires the jq
tool available from homebrew)
cd ~/Library/Group\ Containers/group.com.docker/
mv settings.json settings.json.backup
cat settings.json.backup | jq '.["socksProxyPort"]=8888' > settings.json
Restart the app again and, once it's running, go to
Apple System Preferences -> Network -> Advanced -> Proxies
and enable "SOCKS Proxy" using "localhost:8888", hit OK and then Apply.
If you open safari and try browsing, the traffic should be routed via Docker for Mac.
If you start an nginx container:
docker run -d --name nginx nginx
Query the internal IP:
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nginx
It should be possible to open http://<IP>
in Safari.
Let me know if this is helpful or not!