I am building a docker container that should use proxy server when sending HTTP requests. Unfortunately I can't get it to work - I can't authenticate to the proxy from inside the container, even though credentials are correct.
Expected result
curl https://api.myip.com returns JSON response with proxy's IP
Actual result:
curl https://api.myip.com returns curl: (56) Received HTTP code 407 from proxy after CONNECT
What I tried:
- setting HTTP_PROXY env variables (same for HTTPS env)
- adding "Acquire::http::Proxy" string to /etc/apt/apt.conf (same for https)
- tried different configurations (only ENV, only apt.conf file, both)
What I checked:
- /etc/apt/apt.conf contains desired lines (provided below)
- ENVs are set correctly inside the container
- proxy is working correctly outside the container
- proxy authentication works correctly (authorization successful) via browser run from outside the container
- docker networking works properly (no problems when not using proxy)
my apt.conf:
Acquire::http::Proxy "http://<my_login>:<my_pass>@<proxy_ip>:<proxy_port>/";
Acquire::https::Proxy "https://<my_login>:<my_pass>@<proxy_ip>:<proxy_port>/";
Acquire::socks::Proxy "socks://<my_login>:<my_pass>@<proxy_ip>:<proxy_port>/";
my Dockerfile:
from ubuntu:latest
COPY ./rss/apt.conf /apt.conf
ENV HTTP_PROXY=<ip>:<port>
ENV HTTPS_PROXY=<ip>:<port>
RUN apt update && apt install -y curl
RUN cat /apt.conf >> /etc/apt/apt.conf
ENTRYPOINT ["sleep","1000"]
Docker version:
Docker version 20.10.8, build 3967b7d