Add local registry mirror or http(s) proxy to docker on ubuntu 16.04

Create this folder if this /etc/systemd/system/docker.service.d/ if it does not exist yet.

For adding local registry mirror add override.conf and file to the folder and the following config


sudo mkdir /etc/systemd/system/docker.service.d/
sudo vi /etc/systemd/system/docker.service.d/override.conf


[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// --registry-mirror=http://10.0.0.7:5000

For adding proxy to docker add proxy.conf with the following config


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


[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/" "HTTPS_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.0,10.0.0.7"

excluding 10.0.0.7 because, that my local registry mirror 😉 in both cases you need to reload the systemd and docker daemon to take effect.


sudo systemctl daemon-reload
sudo service docker restart

After reload run
sudo docker system info
and see output to confirm the changes have taken effect


..
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Http Proxy: http://proxy.example.com:80/
Https Proxy: http://proxy.example.com:80/
No Proxy: localhost,127.0.0.0,10.0.0.7
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
http://10.0.0.7:5000/
Live Restore Enabled: false

1 comment

Leave a Reply