2015-02-05

Using Docker Behind a Network Proxy

I was working on spinning up some Docker containers (if you haven't heard of Docker, I highly recommend it) and found some difficulty getting it to pull images from behind a proxy. You can manually export the http_proxy and https_proxy settings prior to execution or fire up the Docker service from a script that exports those prior to running the Docker service, but those are both hack-like to me, so I found a better way.

On CentOS (in my case 6.5), simple edit the file docker-network in /etc/sysconfig and add the lines:

export HTTP_PROXY=http://proxy.mynetwork.net:80/
export HTTPS_PROXY=http://proxy.mynetwork.net:80/

Then restart the docker service with service docker restart and you should be able to pull down images!

To go along with that, you should be able to include username/password for proxies as you normally would, "http://<user>:<password>@<host>:<port>"

No comments:

Post a Comment