纯手工在内网部署一个Docker私有仓库
下载Docker仓库的镜像
这个镜像不太好找,有需要的可以从下面的地址中下载。
通过百度网盘分享的文件:registry_2_6.tar
链接:https://pan.baidu.com/s/1dDnsb9Tu3rSfgZDatlpaqw
提取码:1111
上传仓库的镜像
root@rz-133-jiaofu-demo:~# rz
rz waiting to receive.
root@rz-133-jiaofu-demo:~# ls registry_2_6.tar
registry_2_6.tar
导入仓库的镜像
root@rz-133-jiaofu-demo:~# docker image load -i registry_2_6.tar
7444ea29e45e: Loading layer [==================================================>] 4.671MB/4.671MB
e414ec287de6: Loading layer [==================================================>] 1.56MB/1.56MB
cbc119ee9885: Loading layer [==================================================>] 22.79MB/22.79MB
169631782bfc: Loading layer [==================================================>] 3.584kB/3.584kB
9c158fac7d21: Loading layer [==================================================>] 2.048kB/2.048kB
Loaded image: registry:2.6
root@rz-133-jiaofu-demo:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry 2.6 16442cfd83a0 About an hour ago 28.5MB
root@rz-133-jiaofu-demo:~#
启动仓库镜像
root@rz-133-jiaofu-demo:~/docker_registry# pwd
/root/docker_registry
root@rz-133-jiaofu-demo:~/docker_registry# tree
.
└── data
2 directories, 0 files
root@rz-133-jiaofu-demo:~/docker_registry# docker run -d \
> --restart=always \
> --name registry \
> -p 5000:5000 \
> -v ./data:/var/lib/registry \
> registry:2.6
2d2db11322ba0f3adc67cf5e710382843142cf4af87d12b2231d017b63f37a9f
root@rz-133-jiaofu-demo:~/docker_registry# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2d2db11322ba registry:2.6 "/entrypoint.sh /etc…" 14 seconds ago Up 14 seconds 0.0.0.0:5000->5000/tcp, :::5000->5000/tcp registry
root@rz-133-jiaofu-demo:~/docker_registry#
启动成功后,可以使用下面的地址查看仓库中的镜像。
root@rz-133-jiaofu-demo:~# curl http://192.168.2.133:5000/v2/_catalog
{"repositories":[]}
root@rz-133-jiaofu-demo:~#
由于我们第一次创建,仓库中还没有镜像,返回的列表内容为空。
配置客户端的Docker
(base) root@delivery:~# cat /etc/docker/daemon.json
{
"insecure-registries":["192.168.2.133:5000"]
}
(base) root@delivery:~# systemctl restart docker
(base) root@delivery:~#
上传镜像到本地仓库
(base) root@delivery:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
wekanteam/wekan latest 38034018078c 2 months ago 917MB
postgres 12.19 842534c87032 2 months ago 419MB
mongo 6 2a9f5cd13295 3 months ago 729MB
tomsik68/xampp 8 b8a0b6811d82 3 years ago 1.37GB
(base) root@delivery:~# docker tag postgres:12.19 192.168.2.133:5000/postgres:12.19
(base) root@delivery:~# docker push 192.168.2.133:5000/postgres:12.19
The push refers to repository [192.168.2.133:5000/postgres]
92c68d39dffe: Pushed
76fa81909294: Pushed
6f243ca17294: Pushed
e62afabdf0d2: Pushed
5326418f37bb: Pushed
a2c7b30d746c: Pushed
08df831adf52: Pushed
93bb50f9a217: Pushed
2ad378562a2d: Pushed
0f9ffe44ee5c: Pushed
c74f1d4d630a: Pushed
304e63d4a78c: Pushed
ffff242309b4: Pushed
e0781bc8667f: Pushed
12.19: digest: sha256:7a26a6bdc084f05c7ed762009e481f535157f82e77a25e742852c2bb3d61052d size: 3247
(base) root@delivery:~# curl 192.168.2.133:5000/v2/_catalog
{"repositories":["postgres"]}
(base) root@delivery:~#
从本地仓库拉取镜像
(base) root@delivery:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
wekanteam/wekan latest 38034018078c 2 months ago 917MB
postgres 12.19 842534c87032 2 months ago 419MB
mongo 6 2a9f5cd13295 3 months ago 729MB
tomsik68/xampp 8 b8a0b6811d82 3 years ago 1.37GB
(base) root@delivery:~# docker pull 192.168.2.133:5000/postgres:12.19
12.19: Pulling from postgres
Digest: sha256:7a26a6bdc084f05c7ed762009e481f535157f82e77a25e742852c2bb3d61052d
Status: Downloaded newer image for 192.168.2.133:5000/postgres:12.19
192.168.2.133:5000/postgres:12.19
(base) root@delivery:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
wekanteam/wekan latest 38034018078c 2 months ago 917MB
postgres 12.19 842534c87032 2 months ago 419MB
***************************************************************************
192.168.2.133:5000/postgres 12.19 842534c87032 2 months ago 419MB
***************************************************************************
mongo 6 2a9f5cd13295 3 months ago 729MB
tomsik68/xampp 8 b8a0b6811d82 3 years ago 1.37GB
(base) root@delivery:~#