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



跟进如何配置docker容器代理?

我有问题通过我的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下。
  • 我也试图通过--net=host从docker cli,但结果是相同的。

我错过了什么?

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

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

最新更新