Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Installing docker behind a proxy

Installing docker behind a proxy

If you are trying to install docker behind a proxy, you might run into multiple problems. The first one is getting the gpg key for apt. From the install instructions for ubuntu, you see the directive to download the apt key. What they don't tell you on that page is that you need an extra cli option like so:

sudo apt-key adv **--keyserver-options http-proxy=http://proxy.example.com:8080/** --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

Pulling images behind a proxy

And then of course since you're behind that proxy, you might have issues with docker downloading images. Here are the condensed instructions from the full explanation at the official docker docs.

mkdir /etc/systemd/system/docker.service.d
cat </etc/sytemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"
EOF
systemctl daemon-reload
systemctl restart docker

Reference

  • http://askubuntu.com/a/252082/533065
  • http://stackoverflow.com/questions/23111631/cannot-download-docker-images-behind-a-proxy#28093517
  • https://docs.docker.com/engine/admin/systemd/#http-proxy

Comments