赞
踩
1、系统配置
服务端:centos 7
客户端:Windows 10
2、搭建服务端
# 下载 registry
docker pull registry
# 挂载相关的配置
mkdir -p /docker/registry/auth
# 生成账号密码:name password123
docker run --entrypoint htpasswd registry:latest -Bbn name password123 >> /docker/registry/auth/htpasswd
# 设置配置文件
mkdir -p /docker/registry/config
vim /docker/registry/config/config.yml
# 输入以下文件
1
2
3
4
5
6
7
8
9
10
version: 0.1
log:
fields:
service: registry
storage:
delete:
enabled: true
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /var/lib/registry
http:
addr: :5000
headers:
X-Content-Type-Options: [nosniff]
health:
storagedriver:
enabled: true
interval: 10s
threshold: 3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
启动:
docker run -d -p 5005:5000 --restart=always --name=registry \
-v /docker/registry/config/:/etc/docker/registry/ \
-v /docker/registry/auth/:/auth/ \
-e "REGISTRY_AUTH=htpasswd" \
-e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
-v /docker/registry/:/var/lib/registry/ \
registry
1
2
3
4
5
6
7
8
3、配置Windows客户端
1、登录搭建的私有docker仓库
docker login 106.114.114.114:5005
输入用户名密码,这个地方会报错,解决办法会贴截图
Error response from daemon: Get https://106.114.114.114:5005/v2/: http: server gave HTTP response to HTTPS client
2、标记本地镜像
# docker tag 选择一个镜像 服务端IP:端口/镜像名:版本
docker tag redis:latest 106.114.114.114:5005/redis:latest
3、推送镜像到仓库
docker push 106.114.114.114:5005/redis:latest
1
2
3
4
5
6
7
8
9
4、配置centos客户端
1、# 一样的操作,我们先登录
docker login 106.114.114.114:5005
# Error response from daemon: Get https://106.114.114.114:5005/v1/users/: dial tcp 106.114.114.114:5005: i/o timeout
# 解决:https://blog.csdn.net/quanqxj/article/details/79479943
# Error response from daemon: Get https://106.114.114.114:5005/v2/: http: server gave HTTP response to HTTPS client
# 解决:
# vim /etc/docker/daemon.json
# 添加如下内容
# {"insecure-registries":["106.114.114.114:5005","106.114.114.114"]}
2、标记本地镜像
# docker tag 选择一个镜像 服务端IP:端口/镜像名:版本
docker tag redis:latest 106.114.114.114:5005/redis:latest
3、推送镜像到仓库
docker push 106.114.114.114:5005/redis:latest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
5、查看效果
1、到服务端查看:
cd /docker/registry/docker
# 会有一个docker的文件夹
tree
1
2
3
2、到客户端测试:
# 先将我们生成的镜像 rmi 掉
docker rmi 106.114.114.114:5005/redis:latest
# 拉取私库镜像
docker pull 106.114.114.114:5005/redis
1
2
3
4
3、查看私有容器中的所有镜像:
curl -u "name:password123" -X GET http://106.114.114.114:5005/v2/_catalog
1
这就已经成功了
————————————————
版权声明:本文为CSDN博主「Chaim_chen」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_38637558/article/details/99603071
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。