Looking at docs there is no instruction on how to run it behind a proxy. https://docs.docker.com/installation/ubuntulinux/
Reading on forums, the instruction is to update /etc/default/docker to export the proxy setup.
export http_proxy="http://127.0.0.1:3128/" export https_proxy="http://127.0.0.1:3128/" export HTTP_PROXY="http://127.0.0.1:3128/" export HTTPS_PROXY="http://127.0.0.1:3128/"
Then we restart/start docker
sudo service docker start
Inside a container, if I run 'apt-get', npm install, bower install I cant get through the proxy.
Not sure what I m missing.
To configure Docker to work with a proxy you need to add the HTTPS_PROXY / HTTP_PROXY environment variable to the Docker sysconfig file ( /etc/sysconfig/docker ). The Docker repository (Docker Hub) only supports HTTPS.
In Docker 17.07 and higher, you can configure the Docker client to pass proxy information to containers automatically. In Docker 17.06 and earlier versions, you must set the appropriate environment variables within the container.
For Ubuntu 14.04 LTS
who uses SysVinit
, you should modify /etc/default/docker
file:
# cat /etc/default/docker # Docker Upstart and SysVinit configuration file # # THIS FILE DOES NOT APPLY TO SYSTEMD # # Please see the documentation for "systemd drop-ins": # https://docs.docker.com/engine/articles/systemd/ # ....... # If you need Docker to use an HTTP proxy, it can also be specified here. export http_proxy="http://web-proxy.corp.xxxxxx.com:8080/" export https_proxy="https://web-proxy.corp.xxxxxx.com:8080/" ......
Then restart docker
:
service docker restart
For Ubuntu 16.04 LTS
who uses Systemd
, you can follow this post:
(1) Create a systemd drop-in directory:
mkdir /etc/systemd/system/docker.service.d
(2) Add proxy in /etc/systemd/system/docker.service.d/http-proxy.conf
file:
# cat /etc/systemd/system/docker.service.d/http-proxy.conf [Service] Environment="HTTP_PROXY=https://web-proxy.corp.xxxxxx.com:8080/" Environment="HTTPS_PROXY=https://web-proxy.corp.xxxxxx.com:8080/" Environment="NO_PROXY=localhost,127.0.0.1,localaddress,.localdomain.com"
(3) Flush changes:
systemctl daemon-reload
(4) Restart Docker:
systemctl restart docker
Official Reference
For Ubuntu 14.04.2 LTS Linux vagrant-ubuntu-trusty-64 3.13.0-54-generic #91-Ubuntu SMP Tue May 26 19:15:08 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Edit you /etc/default/docker
file
sudo vim /etc/default/docker
Add this line at the bottom:
export http_proxy="http://PROXY_IP:PROXY_PORT"
Restart the docker
service
sudo service docker restart
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With