read

Speed up docker pull from minutes to secounds!

If your using Docker containers in a bigger environment then one host, you’ll soon figure out downloading or pull images takes quite a while, especially if your working against Docker Hub. Even if you have your own registry rolling, you might have more locations with docker hosts, which should all have a local mirror of your own registry.

Solution is local mirroring registrys at your diffrent locations! It’s all very good explained in Docker’s github repo but I’m laying it our here as well.

Let’s do it

  1. Setup Docker daemon on all affected docker hosts. Add --registry-mirror options to the DOCKER_OPTS variable in /etc/default/docker.
  2. Setup a locally registry with mirroring enabled.
docker run -p 5000:5000 \
    -e STANDALONE=false \
    -e MIRROR_SOURCE=https://registry-1.docker.io \
    -e MIRROR_SOURCE_INDEX=https://index.docker.io registry

or against your own central registry:

docker run -p 5000:5000 \
    -e STANDALONE=false \
    -e MIRROR_SOURCE=https://registry.company.com \
    -e MIRROR_SOURCE_INDEX=https://index.docker.io registry

Test it!

First time downloading officially node image.

[email protected]:~# time docker pull node:latest
Pulling repository node
12f018678fb1: Download complete
511136ea3c5a: Download complete
8771fbfe935c: Download complete
0e30e84e9513: Download complete
c90a56bfe7dd: Download complete
6b030fdd4748: Download complete
787349ce806c: Download complete
70a6b638a713: Download complete
380e6bb3cafc: Download complete
0b0b06183499: Download complete
3dd8081876d6: Download complete
Status: Downloaded newer image for node:latest

real 0m47.829s
user 0m0.059s
sys 0m0.030s

Removing image.

[email protected]:~# docker rmi node:latest
Untagged: node:latest

Second download of the same image, now being fetched from local cache.

[email protected]:~# time docker pull node:latest
Pulling repository node
12f018678fb1: Download complete
511136ea3c5a: Download complete
8771fbfe935c: Download complete
0e30e84e9513: Download complete
c90a56bfe7dd: Download complete
6b030fdd4748: Download complete
787349ce806c: Download complete
70a6b638a713: Download complete
380e6bb3cafc: Download complete
0b0b06183499: Download complete
3dd8081876d6: Download complete
Status: Image is up to date for node:latest

real 0m2.456s
user 0m0.008s
sys 0m0.004s

A big diffrent, and if your running a lot of docker hosts in the same location this will not only save you time but bandwidth.

Blog Logo

Love Billingskog Nyberg


Published

Image

jacksoncage

A blog about sysadmin, devops, automation, containers and awesomeness!

Back to Overview