https://stackoverflow.com/questions/23111631/cannot-download-docker-images-behind-a-proxy
mkdir /etc/systemd/system/docker.service.d
cat << EOF > /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"
Environment="HTTPS_PROXY=http://proxy.example.com:80/"
Environment="NO_PROXY=localhost,127.0.0.1,::1"
EOF
sudo systemctl daemon-reload
sudo systemctl show --property Environment docker
sudo systemctl restart docker
from https://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo
usermod -aG docker $USER
and relogin or run newgrp docker
Note: adding user to the docker
group basically gives them root
privileges.
per https://stackoverflow.com/questions/46444026/use-proxy-inside-a-docker-container
run the command with environment:
FROM ubuntu
RUN export "http_proxy=http://host:port" \
&& export "https_proxy=http://host:port" \
&& apt-get update \
&& apt-get install -y SOME-PACKAGE
or add the environment to the whole Dockerfile:
FROM ubuntu
ENV http_proxy http://host:port
ENV https_proxy http://host:port
RUN apt-get update \
&& apt-get install -y SOME-PACKAGE
This will work for apt-get
. Things like Maven have their own environment variables:
ENV MAVEN_OPTS -Dhttp.proxyHost=www-proxy-lon.uk.oracle.com -Dhttp.proxyPort=80 -Dhttps.proxyHost=www-proxy-lon.uk.oracle.com -Dhttps.proxyPort=80
NOTE: these ENV
entries have to be repeated after each FROM
in given Dockerfile.