We may want to build and store images that contain information or data that we do not want to expose, because the Docker team opens up Docker-registry code so that we can run our own registry internally based on this code.
Service side
1. Pull away the warehouse image
[email protected] ~]# Docker pull registry:2.1.1
2. View containers
[[email protected] ~]# Docker PS
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
38802006b373 docker.io/registry:2.1.1 "/bin/registry/etc/24 hours ago up 5 minutes 0.0.0.0:5000->5000/tcp Registry
3. Start the container
[email protected] ~]# Docker run-d-v/opt/registry:/var/lib/registry-p 5000:5000--restart=always--name Registry Regi stry:2.1.1
Important: By default, the warehouse will be stored in the container's/var/lib/registry directory, so if the container is deleted, then the image stored in the container will be lost, so we typically specify a local directory attached to the container's/opt/registry, Two directories are available!
The default storage path for registry is/tmp/registry, which is just a temporary directory that disappears after a period of time
• Use the-v parameter to specify a local persistent path.
4. Access the http://ip:5000 port, the following interface appears, which indicates that the warehouse installation was successful
Client
1. Pull the image
[email protected] ~]# Docker pull BusyBox
2. Label the image
[email protected] ~]# Docker tag Docker.io/busybox 192.168.0.38:5000/busybox
[email protected] ~]# Docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
Docker.io/busybox latest 0064fda8c45d 5 days ago 1.113 MB
<none> <none> 42316db2cd8d days ago 187.9 MB
Docker.io/registry latest A8706c2bfd21 2 weeks ago 422.8 MB
Docker.io/ubuntu 14.04 d55e68e6cc9c 2 weeks ago 187.9 MB
3. Edit the Docker profile, specify the private warehouse URL
[Email protected] ~]# Vim/etc/sysconfig/docker
options= '--insecure-registry 192.168.0.38:5000 '
[[Email protected] ~]# service Docker restart
4. Upload the image to the warehouse
Docker Push 192.168.0.38:5000/busybox
5. View private Warehouses
[Email protected] ~]# Curl 192.168.0.38:5000/v1/search
{"Num_results": 1, "Query": "", "results": [{"description": "", "Name": "Library/busybox"}]}
Install docker-registry2.0 based on CENTOS7