Carlos Vargas

Docker Containers behind a proxy

Blog Post created by Carlos Vargas on Aug 2, 2016

Introduction

 

I was designing a solution with a team to the best architects in the industry and we hit a road block. The solution was going to be deployed in an environment where there was a proxy.  Everything in the Linux OS worked with proxy but all the sudden docker will not connect to the registry to download what it needed.

After doing some research and reading a ton of posts here is a quick guide how to setup your docker environment if you have a proxy.

 

First, create a systemd drop-in directory for the docker service:

 

mkdir /etc/systemd/system/docker.service.d

 

Edit the configuration file for docker environment

Now create a file called /etc/systemd/system/docker.service.d/http-proxy.conf that adds the HTTP_PROXY environment variable:

 

sudo vi /etc/systemd/system/docker.service.d/http-proxy.conf

 

[Service]

Environment="HTTP_PROXY=http://proxy.example.com:80/"

 

 

Proxy Bypass List

If you have internal Docker registries that you need to contact without proxying you can specify them via the NO_PROXY environment variable:

 

Environment="HTTP_PROXY=http://proxy.example.com:80/"

Environment="NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com"

 

 

Flush changes

sudo systemctl daemon-reload

 

Verify that the configuration has been loaded

 

sudo systemctl show docker --property Environment

Environment=HTTP_PROXY=http://proxy.example.com:80/

 

 

Restart Docker

sudo systemctl restart docker

 

 

References:

 

http://containerking.ninja/2016/08/02/docker-containers-behind-a-proxy/

https://docs.docker.com/engine/admin/systemd/#http-proxy

http://stackoverflow.com/questions/23111631/cannot-download-docker-images-behind-a-proxy

 

Original Post: Docker Containers behind a proxy – Container King

 

Hitachi Developer Network

Outcomes