CAUTION : If you are in Linux environement (no boot2Docker) use directly Docker http-proxy
This example overrides the default docker.service file.
$ mkdir /etc/systemd/system/docker.service.d
Create/Edit file : /etc/systemd/system/docker.service.d/http-proxy.conf
and add following
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"
Flush changes:
$ sudo systemctl daemon-reload
Restart Docker:
$ sudo systemctl restart docker
Posted on 17/07/2014 by nickytd
If you use docker behind a proxy you need to specify the corresponding environment variables to download images from internet. In my case I use docker on a mac os hence I use boot2docker Linux based virtual machine to host the docker process. Here are few simple steps to configure the proxy for boot2docker (version 1.1.1):
- Login to the host vm
bash-3.2$ boot2docker ssh
- find where the docker configuration is stored
docker@boot2docker:~$ ls -la /etc/init.d/docker
lrwxrwxrwx 1 root root 28 Jul 17 07:46 /etc/init.d/docker -> /usr/local/etc/init.d/docker
- If you cat the startup script you’ll see something like
#import settings from profile (e.g. HTTP_PROXY, HTTPS_PROXY)
test -f "/var/lib/boot2docker/profile" && . "/var/lib/boot2docker/profile"
- Check to see if profile file exists and add the needed configuration
vi /var/lib/boot2docker/profile
# Add lines :
export HTTP_PROXY=http://{proxy_host}:{proxy_port}
export HTTPS_PROXY=https://{proxy_host}:{proxy_port}
- Restart the docker process
sudo /etc/init.d/docker restart
That’s it now you can pull docker images if you’re behind a proxy.