当前位置: 首页 > 工具软件 > registry > 使用案例 >

Docker之registry安装部署

秦晋
2023-12-01

Docker之registry安装部署

我说了您可能就不会继续看registry了,但是我还是要说,这个东东真不好用,不如harbor(强烈推荐)。

1、安装docker

……此处省略……

2、拉取registry镜像

[root@registry ~]# docker pull registry
Using default tag: latest
latest: Pulling from library/registry
6a428f9f83b0: Pull complete 
90cad49de35d: Pull complete 
b215d0b40846: Pull complete 
429305b6c15c: Pull complete 
6f7e10a4e907: Pull complete 
Digest: sha256:265d4a5ed8bf0df27d1107edb00b70e658ee9aa5acb3f37336c5a17db634481e
Status: Downloaded newer image for registry:latest
docker.io/library/registry:latest
[root@registry ~]# 

3、创建授权使用目录

[root@registry ~]# mkdir -pv  /root/auth
mkdir: 已创建目录 "/root/auth"

4、创建授权文件

创建授权有两张方式(设置用户、密码):
①、通过docker run --entrypoint htpasswd ……我用此命令创建有大量的报错
②、通过linux自带的htpasswd(httpd服务)创建

docker run --entrypoint htpasswd registry:latest -Bbn user91 password91 > /root/auth/htpasswd  #通过docker容器中htpasswd创建文件
htpasswd -bc htpasswd zqj zqj >> /root/auth/htpasswd #通过htpasswd命令生成文件

注:本文档采用本机htpasswd直接生成。

5、regisry启动

docker  run -d -p 5000:5000 --restart=always --name myRegistry01 -v /root/auth/htpasswd:/root/auth/htpasswd -e "REGISTRY_AUTH=htpasswd" -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" -e "REGISTRY_AUTH_HTPASSWD_PATH=/root/auth/htpasswd" registry

6、验证registry与上传镜像

此处需要注意的是,Registry默认登录是https服务验证,如果需要通过http登录则需要在daemon.json中增加如下配置:
vim /etc/docker/daemon.json

{ “insecure-registries”:[“192.168.3.192:5000”]}

[root@registry ~]# docker login 192.168.3.192:5000
Username: zqj
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded

[root@registry ~]# docker push 192.168.3.192:5000/nginx:v1 
The push refers to repository [192.168.3.192:5000/nginx]
fac15b2caa0c: Pushed 
f8bf5746ac5a: Pushed 
d11eedadbd34: Pushed 
797e583d8c50: Pushed 
bf9ce92e8516: Pushed 
d000633a5681: Pushed 
v1: digest: sha256:6fe11397c34b973f3c957f0da22b09b7f11a4802e1db47aef54c29e2813cc125 size: 1570

7、拉取镜像

[root@registry ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              ad4c705f24d3        14 hours ago        133MB
registry            latest              b2cb11db9d3d        9 days ago          26.2MB
[root@registry ~]# docker pull 192.168.3.192:5000/nginx:v1
v1: Pulling from nginx
Digest: sha256:6fe11397c34b973f3c957f0da22b09b7f11a4802e1db47aef54c29e2813cc125
Status: Downloaded newer image for 192.168.3.192:5000/nginx:v1
192.168.3.192:5000/nginx:v1
[root@registry ~]# docker images
REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
192.168.3.192:5000/nginx   v1                  ad4c705f24d3        14 hours ago        133MB
nginx                      latest              ad4c705f24d3        14 hours ago        133MB
registry                   latest              b2cb11db9d3d        9 days ago          26.2MB
[root@registry ~]# 
 类似资料: