搭建本地镜像仓库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| [root@localhost ~] [root@localhost opt] 总用量 1281480 -rw-r--r--. 1 root root 1312232098 4月 11 17:55 registry.tar.gz [root@localhost opt] [root@localhost registry-data] REPOSITORY TAG IMAGE ID CREATED SIZE
[root@localhost opt] registry-data registry.tar.gz [root@localhost opt]
[root@localhost registry-data] 总用量 25728 drwxr-xr-x. 3 root root 20 4月 9 2020 registry -rw-------. 1 root root 26344448 4月 9 2020 registry-v2.tar [root@localhost registry-data] registry/ registry-v2.tar [root@localhost registry-data] 7444ea29e45e: Loading layer 4.671MB/4.671MB 9d08b7a37338: Loading layer 1.563MB/1.563MB c62467775792: Loading layer 20.08MB/20.08MB 588f0b714a86: Loading layer 3.584kB/3.584kB a330d9dc14ce: Loading layer 2.048kB/2.048kB Loaded image: registry:2
[root@localhost registry-data] REPOSITORY TAG IMAGE ID CREATED SIZE registry 2 708bc6af7e5e 14 months ago 25.8MB
|
docker镜像启动镜像仓库服务
1 2 3
| $ docker run -d -p 5000:5000 --restart always -v /opt/registry-data/registry:/var/lib/registry --name registry registry:2
|
假设启动镜像仓库服务的主机地址为192.168.56.10,该目录中已存在的镜像列表:
现镜像仓库地址 |
原镜像仓库地址 |
192.168.56.10:5000/coreos/flannel:v0.11.0-amd64 |
quay.io/coreos/flannel:v0.11.0-amd64 |
192.168.56.10:5000/mysql:5.7 |
mysql:5.7 |
192.168.56.10:5000/nginx:alpine |
nginx:alpine |
192.168.56.10:5000/centos:centos7.5.1804 |
centos:centos7.5.1804 |
192.168.56.10:5000/elasticsearch/elasticsearch:7.4.2 |
docker.elastic.co/elasticsearch/elasticsearch:7.4.2 |
192.168.56.10:5000/fluentd-es-root:v1.6.2-1.0 |
gcr.io/google_containers/fluentd-elasticsearch:v2.4.0 |
192.168.56.10:5000/kibana/kibana:7.4.2 |
docker.elastic.co/kibana/kibana:7.4.2 |
192.168.56.10:5000/kubernetesui/dashboard:v2.0.0-beta5 |
kubernetesui/dashboard:v2.0.0-beta5 |
192.168.56.10:5000/kubernetesui/metrics-scraper:v1.0.1 |
kubernetesui/metrics-scraper:v1.0.1 |
192.168.56.10:5000/kubernetes-ingress-controller/nginx-ingress-controller:0.30.0 |
quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.30.0 |
推送本地镜像到镜像仓库中
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| $ docker tag nginx:alpine localhost:5000/nginx:alpine $ docker push localhost:5000/nginx:alpine
$ docker tag nginx:alpine 192.168.56.10:5000/nginx:alpine $ docker push 192.168.56.10:5000/nginx:alpine The push refers to repository [172.21.16.3:5000/nginx] Get https://192.168.56.10:5000/v2/: http: server gave HTTP response to HTTPS client
$ cat /etc/docker/daemon.json { "registry-mirrors": [ "https://8xpk5wnt.mirror.aliyuncs.com" ], "insecure-registries": [ "192.168.56.10:5000" ] } $ systemctl restart docker $ docker push 192.168.56.10:5000/nginx:alpine $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE 192.168.56.10:5000/nginx alpine 377c0837328f 4 weeks ago nginx alpine 377c0837328f 4 weeks ago localhost:5000/nginx alpine 377c0837328f 4 weeks ago registry 2 708bc6af7e5e 2 months ago
|