I am running a proxy on my host (torsocks), what should I add in a docker-compose so that all traffic from a container goes through my proxy?
You can learn about the configuration in the official documentation:
Greetings and thanks for replying. Iāve actually been trying that among other things, but it simply doesnāt work. At this point I think itās a bug, I opened an issue on github to see if any luck.
If however you or anyone else wouldnāt mind helping a newbie step by step to check if Iāve made a mistake, Iād be happy to.
You can use a proxy running on a host in a container by using a virtual private network (VPN). This will allow you to transfer data securely between the host and the container. Additionally, you can set up a SOCKS proxy to route traffic from the container to the host. You can use a variety of tools to set up the VPN, such as SSH, OpenVPN, or IPsec. You can also use a reverse proxy such as NGINX or Apache to forward traffic from the host to the container.
did it worked for you?
I donāt think it is a bug in Docker, although it is not impossible, but knowing what kind of application re you talking about could be important. If you use curl or wget, or something like that from shell in the container, the shell should use the proxy, but other applications can ignore it. For example APT has its own proxy settings too (I donāt remember if it ignores the global settings) and you need to set the proxy in systemd because that would not use the variable that you set globally. I donāt have other examples,
An other problem can be that some apps may use http_proxy
instead of HTTP_PROXY
. It shouldnāt matter, but when I had to set a proxy in an entire cluster, I used both variables with the same values to make sure it works.
Update:
I tested the proxy settings with the wget command and realized that needs lower caase variables. http_proxy
and https_proxy
. I also commented on GitHub.
I erred in assuming that applying the proxy would redirect all traffic to it. My bad, sorry, looks like I simply (*gasp) need to learn how to configure my container, and perhaps block leaks with a firewall.
No problem. At least you helped us to realize the documentation could be better