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
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"] }
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!