1

I am trying to setup a VM in a private NAT to use a squid proxy running on a gateway VM to access the internet.

I have configured the internal VM to use the proxy by setting http_proxy, https_proxy in the /etc/environment file. This works i.e. when running curl commands on the VM directly (abridged output):

 curl -v google.com
* Uses proxy env variable no_proxy == '127.0.0.1'
* Uses proxy env variable http_proxy == 'http://xxx.xxx.xxx.xxx:3128'
*   Trying xxx.xxx.xxx.xxx:3128...
* TCP_NODELAY set
* Connected to xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx) port 3128 (#0)
> GET http://google.com/ HTTP/1.1
> Host: google.com
> User-Agent: curl/7.68.0
> Accept: */*
> Proxy-Connection: Keep-Alive
>
...
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

I have also configured the docker daemon with the same proxy variables (via /etc/systemd/system/docker.service.d/proxy.conf ) as i have configured and docker seems to be configured correctly here is the abridged output of docker system info:

...
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http://xxx.xxx.xxx.xxx:3128
 HTTPS Proxy: http://xxx.xxx.xxx.xxx:3128
 No Proxy: localhost,127.0.0.1,::1
...

The problem I am facing now is that inside of docker containers, which are required for our use case, it seems as though either the full proxy or the DNS of the proxy is not used. I get the following output from a container that was run with the above described configuration and an additional HTTP_PROXY env var passed to a curlimages/curl image.

/ $ echo $HTTP_PROXY
http://xxx.xxx.xxx.xxx:3128
/ $ curl -v google.com
* Could not resolve host: google.com
* Closing connection 0
curl: (6) Could not resolve host: google.com

Also when I checked the squid access logs I only see the request made from the VM directly and not the one from inside the container so it seems like the request does not event make it out of the container.

Is there additional any additional DNS configuration that I could do for docker? Is there a different way to check whether the proxy/DNS is used by docker?

Thank you for your help!

1
  • It looks like the HTTP_PROXY variable is set inside the container, but curl is looking for http_proxy (note the capitalization difference).
    – larsks
    Oct 1, 2022 at 12:52

0

You must log in to answer this question.

Browse other questions tagged .