mac系统上访问docker容器中的ip配置

参考地址: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

mac系统上访问docker容器中的ip配置_第1张图片

 

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:// in Safari.

Let me know if this is helpful or not!

你可能感兴趣的:(Docker)