Docker Basics: Private Warehouses Repository Build (1): Registry

Source: Internet
Author: User
Tags docker ps docker run docker registry

After using the Docker login command, you can push the image to the Dockerhub using the push command, but dockerhub on the public web, the free account has only one private repository free, All that remains is to be made public. Due to various restrictions, the creation of enterprise private warehouses has a variety of application scenarios. This article will briefly describe how to build a private repository from the use of registry. Pull Registry Mirror

Registry image to use

[ROOT@LIUMIAOCN ~]# Docker Search Registry |head-n2
NAME                                      DESCRIPTION                                     STARS     official   automated
Registry                                  Containerized Docker Registry                   1123      [OK]
[ROOT@LIUMIAOCN ~]# Docker Pull registry
Using default tag: Latest
latest:pulling from Library/registry
c0cb142e4345:pull complete
a5002dfce871:pull complete
df53ce740974:pull Complete
9ce080a7bfae:pull complete
517dc3530502:pull complete
Digest: sha256:1cfcd718fd8a49fec9ef16496940b962e30e3927012e851f99905db55f1f4199
status:downloaded Newer image for Registry:latest
[ROOT@LIUMIAOCN ~]#
Docker Run creates a private warehouse

The best practices mentioned in Registry's introduction suggest that registry be run as a container.

[ROOT@LIUMIAOCN ~]# Docker run-d-P 5000:5000 Registry
badf822f34751979e4f7fc513b40177f941b227c7385245ad2f391737587b117
[root@liumiaocn ~]# Docker PS
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
badf822f3475        Registry            "/ entrypoint.sh/etc/"   3 seconds ago up       2 seconds        0.0.0.0:5000->5000/tcp   Sharp_khorana
[ ROOT@LIUMIAOCN ~]#
push a mirror to a private warehouse

Preparation: Pull a BusyBox

[Root@liumiaocn ~]# Docker pull BusyBox
Using default tag:latest
latest:pulling from Library/busybox
56bec22e3559:pull Complete
digest:sha256:29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912
status:downloaded Newer image for Busybox:latest
[ROOT@LIUMIAOCN ~]# Docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
busybox             Latest              e02e811dd08f        9 days ago          1.093 MB
Registry            latest              541a6732eadb        3 weeks ago         33.27 MB
[ROOT@LIUMIAOCN ~]#

Preparation: Tag BusyBox

[ROOT@LIUMIAOCN ~]# docker tag busybox localhost:5000/busybox
[root@liumiaocn ~]# docker images
REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
busybox                  latest              e02e811dd08f        9 days ago          1.093 MB
localhost : 5000/busybox   Latest              e02e811dd08f        9 days ago          1.093 MB
Registry                 latest              541A6732EADB        3 weeks ago         33.27 MB
[ROOT@LIUMIAOCN ~]#

Push pushes to a private warehouse

[ROOT@LIUMIAOCN ~]# Docker push localhost:5000/busybox The
push refers to a repository [localhost:5000/busybox]
  e88b3f82283b:pushed
latest:digest:sha256 : 29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912 size:527
[ROOT@LIUMIAOCN ~]#

Results confirmed

[ROOT@LIUMIAOCN ~]# Docker images
REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
busybox                  Latest              e02e811dd08f        9 days ago          1.093 MB
localhost:5000/busybox   latest              e02e811dd08f        9 Days ago          1.093 MB
Registry                 latest              541a6732eadb        3 weeks ago         33.27 MB
[ ROOT@LIUMIAOCN ~]#
Pull mirror from private library

Pre-Preparation: Remove the other mirrors to confirm that the image was actually pull out of the private warehouse

[ROOT@LIUMIAOCN ~]# Docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
Registry            Latest              541a6732eadb        3 weeks ago         33.27 MB

Pull Private Library image

[Root@liumiaocn ~]# Docker pull Localhost:5000/busybox
Using default tag:latest
latest:pulling from Busybox
  56bec22e3559:pull Complete
digest:sha256:29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912
status:downloaded Newer image for Localhost:5000/busybox:latest
[ROOT@LIUMIAOCN ~]# Docker images
REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
localhost:5000/ BusyBox   Latest              e02e811dd08f        9 days ago          1.093 MB
Registry                 latest              541A6732EADB        3 weeks ago         33.27 MB
[ROOT@LIUMIAOCN ~]#

Confirm:
Pull down image can be used normally

[ROOT@LIUMIAOCN ~]# Docker images
REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
localhost:5000/ BusyBox   Latest              e02e811dd08f        9 days ago          1.093 MB
Registry                 latest              541a6732eadb        3 weeks ago         33.27 MB
[root@liumiaocn ~]# docker run-it localhost:5000/busybox/bin/sh
/# hostname
2 4976e98919e
/#

Registry can be used to create a private warehouse, but its user management/graphical interface and other aspects of the function is almost no, very unfriendly, we have also introduced the Habor,habor is based on registry, in the following article we will describe how to use Habor.

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.