Skip to content

Instantly share code, notes, and snippets.

@mikamboo
Last active August 29, 2015 14:16
Show Gist options
  • Save mikamboo/0215513394f9f094489c to your computer and use it in GitHub Desktop.
Save mikamboo/0215513394f9f094489c to your computer and use it in GitHub Desktop.
Docker tips

How to configure Docker when behind a proxy

Linux host

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

boot2Docker

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):

  1. Login to the host vm
 bash-3.2$ boot2docker ssh
  1. 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
  1. 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"
  1. 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}
  1. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment