Create a private repository for docker and a private repository for docker

Source: Internet
Author: User

Create a private repository for docker and a private repository for docker

Thanks to the network speed and the performance of the Greater China LAN, the image download speed in DockerHub is very slow. Even some domestic image warehouses do not feel very fast. Therefore, it is necessary to build an image repository locally or in a place that we can access quickly (your own ECS. With such a repository, we can not only increase the download speed, but also add custom images for future use. This article describes how to build a local image.

In other words, configure the docker proxy

If there is a fast proxy, you can also directly configure the docker proxy to download the image quickly. To build a local image, you also need to download the complete image file from the DockerHub. If the access is slow, the download will be very slow. The method for setting proxy is very simple. Here we use CentOS6.5 as an example.

Find/etc/default/docker, open edit, find the following export http_proxy section, remove the comment and change it to your own proxy.

# Docker Upstart and SysVinit configuration file# Customize location of 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 an HTTP proxy, it can also be specified here.export http_proxy="http://xxxx:port"# This 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 Repository

This document records how to create a local private repository using the image Registry officially provided by Docker. The creation method is the same as that for starting a common image.

1. quickly create an image repository on the private repository server and run the following code:

docker run -p 5000:5000 registry:2.0

After running the preceding command, the registry image is pulled from the DockerHub, the Registry Service is started locally, and port 5000 is listened.

2. List local Images

docker images

  

You can see the registry image and a local ubuntu: 12.04 image.

3. Re-mark a local image as a private repository version. Here, the local ubuntu 12.04 is marked as localhost: 5000/ubuntu: 1204.

docker tag ubuntu:12.04 localhost:5000/ubuntu:1204

View the image again and you will see an image marked as localhost: 5000/ubuntu: 1204

4. Push the local image to the local repository

docker push localhost:5000/ubuntu:1204

5. view the image list in the local repository

curl http://localhost:5000/v2/ubuntu/tags/list

The result is as follows:

{"name":"ubuntu","tags":["1204"]}

6. Pull an image from the local warehouse. Before that, run the following command to remove the image that is not used locally to ensure that the image pulled from the local warehouse is not obtained from the cache.

 docker rmi -f $(docker images -q -a )

Then check the image. Only the registry image is left.

Pull images 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 view the image as follows:

  

Last started normally

docker run --name mytestubuntu localhost:5000/ubuntu:1204 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.