github.com/jogo/docker@v1.7.0-rc1/docs/sources/articles/registry_mirror.md (about) 1 page_title: Run a local registry mirror 2 page_description: How to set up and run a local registry mirror 3 page_keywords: docker, registry, mirror, examples 4 5 # Run a local registry mirror 6 7 ## Why? 8 9 If you have multiple instances of Docker running in your environment 10 (e.g., multiple physical or virtual machines, all running the Docker 11 daemon), each time one of them requires an image that it doesn't have 12 it will go out to the internet and fetch it from the public Docker 13 registry. By running a local registry mirror, you can keep most of the 14 image fetch traffic on your local network. 15 16 ## How does it work? 17 18 The first time you request an image from your local registry mirror, 19 it pulls the image from the public Docker registry and stores it locally 20 before handing it back to you. On subsequent requests, the local registry 21 mirror is able to serve the image from its own storage. 22 23 ## How do I set up a local registry mirror? 24 25 There are two steps to set up and use a local registry mirror. 26 27 ### Step 1: Configure your Docker daemons to use the local registry mirror 28 29 You will need to pass the `--registry-mirror` option to your Docker daemon on 30 startup: 31 32 docker --registry-mirror=http://<my-docker-mirror-host> -d 33 34 For example, if your mirror is serving on `http://10.0.0.2:5000`, you would run: 35 36 docker --registry-mirror=http://10.0.0.2:5000 -d 37 38 **NOTE:** 39 Depending on your local host setup, you may be able to add the 40 `--registry-mirror` options to the `DOCKER_OPTS` variable in 41 `/etc/default/docker`. 42 43 ### Step 2: Run the local registry mirror 44 45 You will need to start a local registry mirror service. The 46 [`registry` image](https://registry.hub.docker.com/_/registry/) provides this 47 functionality. For example, to run a local registry mirror that serves on 48 port `5000` and mirrors the content at `registry-1.docker.io`: 49 50 docker run -p 5000:5000 \ 51 -e STANDALONE=false \ 52 -e MIRROR_SOURCE=https://registry-1.docker.io \ 53 -e MIRROR_SOURCE_INDEX=https://index.docker.io \ 54 registry 55 56 ## Test it out 57 58 With your mirror running, pull an image that you haven't pulled before (using 59 `time` to time it): 60 61 $ time docker pull node:latest 62 Pulling repository node 63 [...] 64 65 real 1m14.078s 66 user 0m0.176s 67 sys 0m0.120s 68 69 Now, remove the image from your local machine: 70 71 $ docker rmi node:latest 72 73 Finally, re-pull the image: 74 75 $ time docker pull node:latest 76 Pulling repository node 77 [...] 78 79 real 0m51.376s 80 user 0m0.120s 81 sys 0m0.116s 82 83 The second time around, the local registry mirror served the image from storage, 84 avoiding a trip out to the internet to refetch it.