我想从我的docker容器内通过我本地机器上的Tor代理来ping一个网站。如果不设置代理,我就无法ping。当我运行我的容器时。
sudo docker run --rm -it -p9150:9150 my-container
I got the following error:
Error starting userland proxy: listen tcp 0.0.0.0:9150: bind: address already in use.
我在我的localhost:9150上启动了tor-browser,但我在运行容器时不能做端口转发。另外,我不想在命令中使用
--net=host
。我添加了以下一行
Environment="ALL_PROXY=socks5://127.0.0.1:9150"
到
/lib/systemd/system/docker.service
,但它没有字。有谁能帮我解决这个问题?(操作系统: Ubuntu 20.04)
如何将docker容器连接到本地机器上的tor代理?
6
人关注
Emad Kebriaei
发布于
2020-08-28
1
个回答
Emad Kebriaei
发布于
2020-08-30
已采纳
0
人赞同
To run the TOR proxy and the app
经过我长时间的研究,我得出了以下步骤。
在我的应用程序中,我有一个python脚本,通过tor socks代理向我的telegram频道发送消息。我有一个网络(tor),两个容器通过它互相看到对方。在python脚本中,我有以下一行。
bot = telegram.Bot(token=token, request=Request(con_pool_size=10, connect_timeout=40, proxy_url='socks5h://mytor:9050'))
To manually test the TOR proxy
运行另一个容器,一个通用的容器,比如说
docker run --rm -it --network tor ubuntu:22.04
按常规方法安装curl
(例如在debian/ubuntu中使用apt-get
)。