Hi everyone
I have a docker-compose.yaml file and within it i have 3 image one for frontend one for backend and lase one for database. i should use a proxy on my host for connecting to docker in order to run the container
what i want to do is installing git inside backend image but docker could not connect to host proxy
could any one tell how should i set docker so it could connect through my host proxy for fetching data
my host proxy runs at 127.0.0.1:2081 and any connection to outside network should go through this
when i go into backend bash a want to run apt-get update it could not connect to ubuntu repository
what am i missing?
Localhost or loopback IP adresses would never work as it would mean the processes in the containers would want to connect to the localhost of the container which is not the same as the localhost of the host. You need an IP which can be accesses from the container. It can be the host IP or the docker network gateway ip for example
You understood well, but I missed your proxy-relay service.
Normaly, since 127.0.0.1 always points back to the same network namespace (that is why it is loopback) and it is different in every container and not the same as on the host, unless you run the container in host network mode (except when you run Docker Desktop even with the fake host network enabled) as you did with the proxy-relay service, but then your proxy-relay service will have no ip address and you wil have the same problem with connecting to it. Since you forwarded a host port using socat listening on all interfaces, it should indeed listen on the host gateway, which is the default docker bridge IP. So if you can send the request through that port, it should work.
hHow do you send the request through the host.docker.internal domain? I don’t see the proxy settings in your shared code.
The documentation that you referred is all about setting a proxy for docker ( cli, desktop , …) for connecting to internet
could you please tell me specifically witch part describes how to send request trough host.docker.intenal
You have a proxy on the host, but you forwarded a different port to it for the containers. So that new port is your proxy endpoint that you need to set in the proxy settings described in the documentation. Just use the host.docker.internal domain in the proxy settings. Once you do that, the only problem could be that the app you want to use don’t support proxy variables. But curl will.