微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Mac下将本地代理传递给docker容器

如何解决Mac下将本地代理传递给docker容器

跟进 How to configure docker container proxy?

我在将 localhost 代理传递到 docker 容器时遇到问题:

$ curl --proxy socks5://localhost:18888 https://goolge.ca
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>

docker run -ti -p 18888:18888 ...

# within docker
$ curl --proxy socks5://localhost:18888 https://goolge.ca
curl: (7) Failed to connect to localhost port 18888: Connection refused

$ curl --proxy https://localhost:18888 https://goolge.ca
curl: (7) Failed to connect to localhost port 18888: Connection refused

$ curl --proxy http://localhost:18888 https://goolge.ca
curl: (7) Failed to connect to localhost port 18888: Connection refused

$ curl --proxy socks5://0.0.0.0:18888 https://goolge.ca
curl: (7) Failed to connect to 0.0.0.0 port 18888: Connection refused
  • 这是在 macOS 下。
  • 我也尝试从 docker cli 传递 --net=host,但结果是一样的。

我错过了什么?

解决方法

如果你在 docker 容器的 bash 中运行命令,那么你应该使用

#within docker
$ curl --proxy socks5://0.0.0.0:18888 https://goolge.ca

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。