Use proxies in containers

Hello Friends

I tried many times to use proxy in containers but failed many times.

" I have one image I need to push it with HTTP proxy multi times with different proxies."

For example, I want to pull firefox vnc on many containers with proxies my proxy is IP:port

You can tell me any server best to make it with whatever I will try to do it.

I moved your post to the “General Discussions/General” category, as “Tips & HowTos” is for when you create an article about Tips or How-Tos for others to follow.

Thus said, I am not really sure what you are looking for, as your post is a little ambiguous and shows no example of what you tried. It starts with http_proxy in containers, but then ask’s for any server for it. I have no idea what the server part could mean.

May I ask you to elaborate more about your use case and share the docker run commands you used to create a container that has a problem (or the content of the compose file instead).

1 Like

Thank you for helping to move the post to the appropriate category.
Yes, I am sorry, I did not explain well, I did not use the translator because I am not English and do not speak English well.

Exactly what I’m asking is I have this image

docker run -e APPLICATION_KEY=6adfa338-57d0-4112-9476-a1c49ee19828 otohits/app:latest

I want to put it in more than one container with a different proxy for each container.

My proxies are HTTP (proxyip:port), how I can pull it direct or how to edit config file.

thx

Don’t worry, I am not a native English speaker either :slight_smile:

You can pass the http_proxy as argument to the container:

docker run -e http_proxy=${http_proxy} -e https_proxy=${https_proxy} -e APPLICATION_KEY=6adfa338-57d0-4112-9476-a1c49ee19828 otohits/app:latest

Of course, it depends on the application inside the container, whether it will pick those environment variables up or requires the proxy to be configured in an application specific way. In the later case, it is not possible to make a general recommended… and you would need to consult the documentation of the app about it.

1 Like

I replace http_proxy with ip:port?

docker run -e http_proxy=${205.202.458.5:2222} -e https_proxy=${https_proxy} -e APPLICATION_KEY=6adfa338-57d0-4112-9476-a1c49ee19828 otohits/app:latest

Or send it exactly as you write this. I need to edit the container files

It depends. I assume you are on a Linux and use docker-ce, as your post never mentioned any of the Docker Desktop versions.

Furthermore, I assume that your host already has the http proxy configured, as such what I shared would re-use the existing variables of your host. If the variable does not exist, then variable interpolation would replace ${http_proxy} with an empty string. You can replace ${http_proxy} with http://205.202.458.5:2222 (not surrounded by ${ }!) and of course to the same for the https_proxy environment variable - or remove it, if you don’t need it.

If you need to configure it in a file inside the container, then the easiest way is to use docker cp to copy the file from the container to your host, edit the file, remove the old container and create a new container using a volume-bind, that maps the edited file back into the container.

1 Like

you are my hero , thank you.

Can you share your final solution with us? It will help others that stumble across this thread to see what worked for you as a solution.