table of Contents
1. Build a local warehouse
1.1, download the local warehouse image
[root@localhost docker]# docker pull registry
Using default tag: latest
latest: Pulling from library/registry
cbdbe7a5bc2a: Pull complete
47112e65547d: Pull complete
46bcb632e506: Pull complete
c1cc712bcecd: Pull complete
3db6272dcbfa: Pull complete
....
1.2, modify Docker Service configuration
vi /usr/lib/systemd/system/docker.service
Add new parameters at the end of the ExecStart property--insecure-registry ip:5000
....
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --insecure-registry ip:5000
ExecReload=/bin/kill -s HUP $MAINPID
....
1.3, modify DockerDaemon configuration
vi /etc/docker/daemon.json
Add the following configuration
{
"insecure-registries":["192.168.48.128:5000"] }
1.4, restart the Docker service
[root@localhost docker]# systemctl daemon-reload
[root@localhost docker]# systemctl restart docker
1.5, start the container
[root@localhost docker]# docker run -p 5000:5000 -v /opt/registry:/var/lib/registry --name registry -d registry
81e9d099a95a00cdedb5e12fb1f5f9482f0664f4d4a7f25df2c102e1aa10cda6
1.6, container startup status
[root@localhost docker]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
81e9d099a95a registry "/entrypoint.sh /etc…" 26 seconds ago Up 24 seconds 0.0.0.0:5000->5000/tcp registry
1.7, browser to view local warehouse
[root@localhost docker]# curl http://192.168.48.128:5000/v2/
{
}
Two, push mirror
docker tag [ImageId] ip:5000/[mirror name]:[mirror version number]
docker push ip:5000/[mirror name]:[mirror version number]
docker tag df689c674c72 192.168.48.128:5000/mp:1.0
docker push 192.168.48.128:5000/mp:1.0
Three, pull mirror
docker pull ip:5000/[mirror name]:[mirror version number]
docker pull 192.168.48.128:5000/mp:1.0