Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Docker creates a private warehouse

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

A Repository is a place where images are stored centrally.

One concept that is easily confused is the registration server (Registry). In fact, the registration server is a specific server for managing repositories, there can be multiple repositories on each server, and there are multiple images under each warehouse. In this respect, the warehouse can be thought of as a specific project or catalog. For example, for the warehouse address docker.sina.com.cn/centos:centos63, docker.sina.com.cn is the registration server address, centos is the warehouse name, and centos63 is the tag of the warehouse.

Docker Hub official warehouse

Currently, Docker officially maintains a public repository, Docker Hub, which already contains more than 15000 images. Most of the requirements can be achieved by downloading the image directly in Docker Hub.

Register & log in

You can complete registration and login by entering a user name, password, and mailbox by executing the docker login command on the command line. After successful registration, the user's authentication information is saved in the .docker / con authentication g.json in the local user directory.

# docker login

Basic operation

Users can use the docker search command to find the image in the official repository without logging in, and use the docker pull command to download it locally. For example, search with centos as the keyword:

# docker search centos

You can see that many images containing keywords have been returned, including the image name, description, star (indicating the popularity of the image), whether it is officially created, and whether it is created automatically. The official image description is created and maintained by the official project team, and the automated resource allows users to verify the source and content of the image.

Depending on whether it is officially provided, mirror resources can be divided into two categories. One is a base image like centos, which is called a base or root image. These basic images are created, verified, supported and provided by Docker. Such images often use a single word as the name. There is also a type, such as the mirror anon/centos image, which is created and maintained by users of Docker, often with a user name prefix. You can specify the use of an image provided by a user, such as the anon user, with the prefix user_name/. In addition, when searching, you can specify that only images rated above N stars can be displayed through the-s N parameter.

Create your own private warehouse

1. Run through the official registry container

2. Local installation

We use registry, an official container, to build a private warehouse.

1. First, set the IP address information to the warehouse server. In this case, 20.14.3.122Univer 24

Pre-environment requirements: install docker-ce program and set boot up

2. View the registry container image on docker hub

# docker search registry

Pull the registry image to the local docker pull registry

# docker pull registry

Start the container:

# docker run-d-p 5000 5000-- restart=always-v / opt/registry:/var/lib/registry registry

The warehouse directory for the new registry is at / var/lib/registry

The-v option specifies that the / opt/registry/ directory is mounted to / var/lib/registry/

# docker ps

3. Release TCP 5000 port in the firewall

Firewall-cmd-- add-port=5000/tcp effective immediately firewall-cmd-- add-port=5000/tcp-- permanent permanent

4. Verification

When you can see the return value in json format using curl http://20.14.3.122:5000/v2/_catalog, registry is already running.

# curl http://20.14.3.122:5000/v2/_catalog

5. By default, the dockers registry V2 client uses https protocol to push image to the warehouse server, but now our warehouse server is only configured to support http, so the client will push image failure

# docker tag hello-world:latest 20.14.3.122:5000/hello-wold:latest # docker push 20.14.3.122:5000/hello-world

The error message is: http: server gave HTTP response to HTTPS client

If you want the docker client to support http protocol, you need to add the parameter-insecure- registry your_registry_ip:port when starting docker

Edit / usr/lib/systemd/system/docker.service file

Add-- insecure-registry parameter

Restart docker

[root@localhost ~] # systemctl daemon-reload [root@localhost ~] # systemctl restart docker.service

Or modify the / etc/docker/daemon.json file, restart docker after modification

Then push the image and find it successful.

# docker image list # docker push 20.14.3.122:5000/hello-world # curl http://20.14.3.122:5000/v2/_catalog

You can also pull down on other computers.

# docker pull 20.14.3.122:5000/hello-world

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report