Docker creates a private repository and stores images

Source: Internet
Author: User
Tags docker hub docker run

Although the official docker hub of docker provides a lot of images, it basically includes what we need to use, but its access is slow. If you want to customize the image, sharing among multiple servers is inconvenient to use this image. At this time, we urgently need a local private warehouse. The following figure illustrates the role of a private docker repository.


The docker private repository can be implemented through the docker-registry project and uploaded and downloaded through the HTTP service. Docker-Registry already has ready-made images on docker hub.

  $ docker search registry

Select the first docker hub instance.

  $ docker pull registry
The download process is a bit long. Please wait patiently ~.

  $ docker images
After the Registry image is down, run the following command to start and map the Registry container storage images directory to the/opt/docker/Registry directory of the host server.
  $ docker run -d -p 5000:5000 -v /opt/docker/registry:/tmp/registry registry

After startup, enter http: // host IP: 5000 or http: // host IP: 5000/V1/search in the browser. If it is displayed, the docker private repository has been created. Next, push the local images to the private docker repository.

Now, a tag is created for the local image. The new image name must contain "Host IP: 5000", as shown in the following figure (127.0.0.1 is used as an example here ).

REPOSITORY               TAG                 IMAGE ID            CREATED             VIRTUAL SIZEregistry                 latest              5562556b14f9        8 days ago          422.9 MB127.0.0.1:5000/registry  latest              5562556b14f9        8 days ago          422.9 MB
If the above step is missing and the image is pushed directly, the following error occurs.

[[email protected] ~]$ docker push registryThe push refers to a repository [registry] (len: 1)Sending image list2014/10/27 15:48:25 Error: Status 403 trying to push repository registry: Account is not Active

After executing the following push command, you can view the information stored in the private docker repository at http: // host IP: 5000/V1/search.

  $ docker push 127.0.0.1:5000/registry
Next time you can use the pull command to download it to other servers, it will be much faster. When pull is used, remember to include "Host IP: 5000". Otherwise, download from docker hub instead of private repository. The following command is used.

  $ docker pull 127.0.0.1:5000/registry

At this point, the private repository can access the image.

Docker creates a private repository and stores images

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.