Docker私有仓库搭建
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
环境准备
主机名 | IP | 功能 |
controller | 192.168.100.10 | 搭建私有仓库,上传镜像 |
compute | 192.168.100.20 | 拉取镜像 |
linux版本:Centos7.2
Docker版本:Docker version 20.10.5, build 55c4c88
安装私有仓库
controller:
启动一个registry容器,端口映射5000,提供私有仓库服务
docker run -d -p 5000:5000 --name my_registry registry
使用docker ps 查看 STATUS 为 UP表示启动成功
[root@controller ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
17af7d28ce39 registry "/entrypoint.sh /etc…" 2 seconds ago Up 1 second 0.0.0.0:5000->5000/tcp my_registry
获取一个nginx镜像,修改标签名,上传到本地仓库中
获取镜像
[root@controller ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
a076a628af6f: Pull complete
0732ab25fa22: Pull complete
d7f36f6fe38f: Pull complete
f72584a26f32: Pull complete
7125e4df9063: Pull complete
Digest: sha256:10b8cc432d56da8b61b070f4c7d2543a9ed17c2b23010b43af434fd40e2ca4aa
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
修改标签名
[root@controller ~]# docker tag nginx:latest 192.168.100.10:5000/nginx:latest
[root@controller ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.100.10:5000/nginx latest f6d0b4767a6c 2 months ago 133MB
nginx latest f6d0b4767a6c 2 months ago 133MB
registry latest 678dfa38fcfa 3 months ago 26.2MB
上传到本地仓库
[root@controller ~]# docker push 192.168.100.10:5000/nginx
Using default tag: latest
The push refers to repository [192.168.100.10:5000/nginx]
Get https://192.168.100.10:5000/v2/: http: server gave HTTP response to HTTPS client
可以看到未上传成功,这表示本地仓库默认使用HTTPS协议上传,而当前使用的是非HTTPS协议进行上传,我们需要修改一下配置文件
vi /usr/lib/systemd/system/docker.service
我们将第13行
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
修改成
ExecStart=/usr/bin/dockerd --insecure-registry 192.168.100.10:5000
即可
退出后,重启Docker服务
systemctl daemon-reload
systemctl restart docker
重启registry容器
[root@controller ~]# docker restart my_registry
my_registry
上传 镜像 192.168.100.10:5000/nginx:latest 到本地仓库中
[root@controller /]# docker push 192.168.100.10:5000/nginx:latest
The push refers to repository [192.168.100.10:5000/nginx]
85fcec7ef3ef: Pushed
3e5288f7a70f: Pushed
56bc37de0858: Pushed
1c91bf69a08b: Pushed
cb42413394c4: Pushed
latest: digest: sha256:0b159cd1ee1203dad901967ac55eee18c24da84ba3be384690304be93538bea8 size: 1362
compute拉取私有仓库的镜像
compute:
vi /usr/lib/systemd/system/docker.service
将第13行
vi /usr/lib/systemd/system/docker.service
修改为
ExecStart=/usr/bin/dockerd --insecure-registry 192.168.100.10:5000
退出后,重启Docker服务
systemctl daemon-reload
systemctl restart docker
重启registry容器
[root@controller ~]# docker restart my_registry
my_registry
拉取 镜像 192.168.100.10:5000/nginx:latest
[root@compute ~]# docker pull 192.168.100.10:5000/nginx:latest
latest: Pulling from nginx
a076a628af6f: Pull complete
0732ab25fa22: Pull complete
d7f36f6fe38f: Pull complete
f72584a26f32: Pull complete
7125e4df9063: Pull complete
Digest: sha256:0b159cd1ee1203dad901967ac55eee18c24da84ba3be384690304be93538bea8
Status: Downloaded newer image for 192.168.100.10:5000/nginx:latest
192.168.100.10:5000/nginx:latest
下载成功
GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献3条内容
所有评论(0)