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

该博客详细介绍了如何在Docker for Mac上启用并配置SOCKS代理服务器,步骤包括关闭应用、修改settings.json文件设置代理端口为8888,然后在系统偏好设置中开启SOCKS代理,并通过测试nginx容器验证流量路由。
摘要由CSDN通过智能技术生成

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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值