I have been trying to proxify entire container. But the use of environment variables http_proxy and https_proxy does not work with all the applications, since not all the applications use the environment variables to connect to the network.
Docker container network is not completely isolated when environment variables are used.
As an example traffmonetizer can’t be proxied by using environment variables.
I would like to run multiple containers where each container has unique proxy (usually socks5 proxy with username and password).
The application connection stats can be seen from the dashboard of traffmonetizer and it does not use the socks proxy mentioned and instead shows my VPS IP which means it is directly making connection.
So the container is not network isolated rather environment isolated.
Is there any way to accomplish this by making the container network isolated through proxy?
This is only true if you run your containers with --network=host. Only then the container’s network interface is configured with an absence of network isolation.
Containers attached to a bridge network use their own network namespace and are isolated. Egress traffic is natted and because of that will have your VPS IP. Does this mean the container do not use network isolation? No it does not.
From my perspective using the socks proxy is the responsibility of the application inside the container, not of the container itself. If the application inside the container supports a socks proxy and is configured properly, it should use it.
I am pretty sure this is not what you are looking for, but I am still writing about what other people use: they use a container with a vpn client that establishes a vpn connection, and then let other containers join the network namespace of the container with the vpn client, so that all these containers can use the vpn connection. Are the containers in this scenario network isolated from each other ? No! Are they network isolated from the host and other containers? Yes!.
Thank you for the response. Indeed VPN connection through containers and making use of the VPN container works fine. But the problem is I need to use the proxies that I own instead of VPN IPs. I need something similar to what the VPN client does but it should make connection to my socks5 proxy with username and password instead of actual VPN IP. Could you please suggest how this can be accomplished. Any alternate docker containers which can simulate vpn but by using normal proxies.