How to build a docker private image server

王林
Release: 2020-03-25 15:35:55
Original
2861 people have browsed it

How to build a docker private image server

1. Prepare a server A (docker installed, IP: 192.168.39.111)

2. Build it by running the registry container on server A

docker run -itd -v /my_registry:/var/lib/registry -p 5000:5000 --restart=always --name registry registry:latest
Copy after login

Parameter description:

-itd: Open a pseudo terminal in the container for interactive operations and run in the background;

-v: Change the host’s /data/registry The directory is bound to the container/var/lib/registry directory (this directory is the directory where image files are stored in the registry container) to achieve data persistence;

-p: map port; access 5000 of the host The port accesses the service of the registry container;

--restart=always: This is the restart strategy. If the container exits abnormally, the container will be automatically restarted;

--name registry: Create The container is named registry, you can name it whatever you want;

registry:latest: This is the image that was just pulled;

(recommended tutorial:docker tutorial)

3. Configure "unsafe registry" on local host B, that is: http connection (docker installed, IP: 192.168.39.215)

Edit the daemon.json file, its default location / etc/docker/daemon.json is on Linux or C:\ProgramData\docker\config\daemon.jsonWindows Server. If you use Docker Desktop for Mac or Docker Desktop for Windows, click the Docker icon, select Preferences, and then select Daemon.

If the daemon.json file does not exist, please create it. Restart systemctl restart docker after adding the following content

Assuming there are no other settings in the file, it should have the following content:

{ "insecure-registries" : ["myregistrydomain.com:5000"] }
Copy after login

4. Test push and pull on local host B

(1) First mark the image (the mark needs to add ip, otherwise an error will be reported): docker tag busybox 192.168.39.111:5000/bbx:v1

(2) Push the image: docker push 192.168.39.111:5000 /bbx:v1

(3) If the second step is successful, you can pull it down: docker pull 192.168.39.111:5000/bbx:v1

Summary: Pay attention to the settings The "insecure registry" is set on the push side, not on the mirror server side.

The above is the detailed content of How to build a docker private image server. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!