[Introduction to Docker Basics] Docker builds a warehouse

[Docker] repository

Repository is a place where image files are stored centrally.

Similar to the
[Maven] repository, where various jar packages are stored; the github repository, where various git projects are stored; the official registry provided by Docker is called Docker Hub , where various image templates are stored.

Repositories are divided into two forms: public repositories (Public) and private repositories ( [Private] and private repositories ( [Private] ).
The largest public repository is Docker Hub , which houses a huge number of images for users to download. Domestic public warehouses include Alibaba Cloud, NetEase Cloud, etc.

The process of publishing a local image to a private library is as follows:

1. Registry builds a private warehouse

Docker RegistryIt is an officially provided tool that can be used to build a private image repository

1. Build the environment

Docker Registry is also an image provided by Docker Hub , which can be directly pulled and run.

Pull the Docker Registry
to execute the command

docker pull registry

Run the private library Docker Registry

By default, the warehouse is created in the /var/lib/registry directory of the container. It is recommended to use the container volume mapping to facilitate the host machine joint debugging.

docker run -d -p 5000:5000 -v /app/myregistry/:/tmp/registry --privileged=true registry

View all mirrors in private server

curl http://192.168.xxx.xxx:5000/v2/_catalog

Execute the command, the Registry will return all mirror directories in json format

2. Upload an image to the Registry

1. Configure docker to allow receiving http requests

Modify /etc/docker/daemon.json, add insecure-registriesallow http:

    "registry-mirros": ["https://xxxx.mirror.aliyuncs.com"],
    "insecure-registries": ["192.168.xxx.xxx:5000"]

Then restart docker to make the configuration take effect

# command for centos6 
sudo  chkconfig daemon-reload 
sudo  service docker restart 

# command for centos7 
sudo  systemctl daemon-reload 
sudo  systemctl restart docker

2.push to the private server library

Add a tag corresponding to the private warehouse address (take the myubuntu:1.0.1 image as an example)

Modify the image myubuntu:1.0.1 to the Tag that conforms to the private server specification

docker tag myubuntu:1.0.1 192.168.xxx.xxx:5000/myubuntu:1.0.1

docker push

docker push 192.168.xxx.xxx:5000/myubuntu:1.0.1

View the mirror directory verification in the private warehouse

curl http://192.168.xxx.xxx:5000/v2/_catalog

pull to local and run

docker pull 192.169.xxx.xxx:5000/myubuntu:1.0.1


The above is the whole content of [First Know Docker | Basics] Docker builds a warehouse !

It is not easy to create, following💖, like👍, favorite🎉 is the greatest encouragement to the author👏, welcome to comment below🧐

Leave a Comment

Your email address will not be published. Required fields are marked *