Because of the network speed and the Greater China LAN effect, so that we in the Dockerhub download the image is very slow, and even some domestic mirror warehouse, but also feel that the speed is not very good. Therefore, it is necessary to build a set of mirrored warehouses locally or in a very fast place (our own cloud server). With such a warehouse, not only can we increase the download speed, but also we can add a personalized image for future use. This article will show you how to build a local image.
Outside of the session, configure the Docker agent
If you have a quick proxy, of course, you can also directly configure the Docker agent to achieve the purpose of fast download mirroring. The process of building a local mirror also requires downloading the full image file from the Dockerhub, which will be very slow if the access is slow. The method of setting up the proxy is very simple, for example, CentOS6.5.
Find/etc/default/docker, open the editor, find the Export http_proxy section below, remove the comment and modify it as your own agent.
# docker upstart and Sysvinit configuration file# Customize location of the Docker binary (especially for development testing) . #DOCKER = "/usr/local/bin/docker" # Use Docker_opts to modify the daemon startup options. #DOCKER_OPTS = "--dns 8.8.8.8--dns 8.8.4.4 "# If you need Docker-to-use a HTTP proxy, it can also be specified here.export http_proxy=" Http://xxxx:port "# Thi S is also a handy place to tweak where Docker ' s temporary files go. #export tmpdir= "/mnt/bigdrive/docker-tmp" docker_opts= "- -insecure-registry dl.dockerpool.com:5000 "
Create a private warehouse
This document records the creation of a local private warehouse with the image registry provided by Docker, in the same way that it is created and started with a normal image.
1. Quickly create a mirrored warehouse in a private warehouse server and run the following code:
Docker Run-p 5000:5000 registry:2.0
After running the above command, the registry image is pulled from the Dockerhub and the Registry service is started locally and the 5000 port is monitored.
2. List local Mirrors
Docker images
You can see the image of registry and a local ubuntu:12.04 mirror.
3. Re-mark a local image as a private repository version, where the local Ubuntu 12.04 is marked as localhost:5000/ubuntu:1204.
Docker tag ubuntu:12.04 localhost:5000/ubuntu:1204
Look at the mirror again to see one more image labeled localhost:5000/ubuntu:1204
4. Push the local image to the local repository
Docker Push localhost:5000/ubuntu:1204
5. View a list of mirrors in the local repository
Curl Http://localhost:5000/v2/ubuntu/tags/list
The results are as follows:
{"Name": "Ubuntu", "tags": ["1204"]}
6. Pull a mirror from the local repository, then remove the locally unused image by executing the following command, ensuring that the image pulled from the local repository is not fetched from the cache.
Docker Rmi-f $ (Docker images-q-a)
Then look at the image, leaving only registry this image
Pull a mirror from the local repository
Docker pull localhost:5000/ubuntu:1204unable to find image ' localhost:5000/ubuntu:1204 ' locally1204:pulling from Localhost:5000/ubuntub796a17a2688:pull Complete 273721eafe54:pull Complete 7dd38dbb5eda:pull complete 32190de3770a: already exists
Then look at the image as follows:
Last normal start
Docker Run--name Mytestubuntu localhost:5000/ubuntu:1204
Docker creates a private warehouse