当前位置:   article > 正文

docker registry web ui 及私有镜像仓库 安装配置记录_docker-registry-web

docker-registry-web

本次安装记录基于docker 安装,宿主机ip:192.168.5.16

1,创建宿主机目录(用于存放容器配置文件):

  1. /securitit/registry/certs/
  2. /securitit/registry/auth/
  3. /securitit/registry/conf/
  4. /securitit/registry/db/
  5. /securitit/registry/data/registry/

2,使用openssl生成证书和RSA私钥:

openssl req -new -newkey rsa:4096 -days 365 -subj "/CN=localhost" -nodes -x509 -keyout /securitit/registry/auth/auth.key -out /securitit/registry/auth/auth.cert

未安装openssl 需要先安装openssl再生成证书密钥: 

  1. ubuntu: apt-get install -y openssl
  2. centos: yum install -y openssl

3,创建docker registry容器

创建配置文件:/securitit/registry/conf/registry-srv.yml

内容:

  1. version: 0.1
  2. log:
  3. fields:
  4. service: registry
  5. storage:
  6. delete:
  7. enabled: true
  8. cache:
  9. blobdescriptor: inmemory
  10. filesystem:
  11. rootdirectory: /var/lib/registry
  12. http:
  13. addr: 0.0.0.0:5000
  14. headers:
  15. X-Content-Type-Options: [nosniff]
  16. health:
  17. storagedriver:
  18. enabled: true
  19. interval: 10s
  20. threshold: 3
  21. auth:
  22. token:
  23. # registry-web的地址.
  24. realm: http://192.168.5.16:5050/api/auth
  25. # 私有仓库的配置地址.
  26. service: 192.168.5.16:5000
  27. # 需要与registry-web定义的名称一致.
  28. issuer: 'my issuer'
  29. # 容器内证书路径,容器启动时通过数据卷参数指定.
  30. rootcertbundle: /etc/docker/registry/auth.cert

拉取镜像:

docker pull registry

创建容器:

  1. docker run -v /securitit/registry/conf/registry-srv.yml:/etc/docker/registry/config.yml \
  2. -v /securitit/registry/data/registry:/var/lib/registry -v /securitit/registry/auth/auth.cert:/etc/docker/registry/auth.cert -p 5000:5000 --name registry-srv -d registry

4,创建docker registry web ui容器

创建配置文件:/securitit/registry/conf/registry-web.yml

内容:

  1. registry:
  2. # 私有仓库地址.
  3. url: http://192.168.5.16:5000/v2
  4. # 私有仓库命名.
  5. name: 192.168.5.16:5000
  6. # 是否只读设置.
  7. readonly: false
  8. auth:
  9. # 是否进行鉴权处理.
  10. enabled: true
  11. # 需要与私有仓库定义的名称一致.
  12. issuer: 'my issuer'
  13. # 容器内私钥证书路径,容器启动时通过数据卷参数指定.
  14. key: /conf/auth.key

拉取镜像:

docker pull hyper/docker-registry-web

创建容器:

  1. docker run -it -d -v /securitit/registry/conf/registry-web.yml:/conf/config.yml \
  2. -v /securitit/registry/auth/auth.key:/conf/auth.key -v /securitit/registry/db:/data \
  3. -p 5050:8080 --name registry-web hyper/docker-registry-web

5,访问 http://192.168.5.16:5050/ 默认用户名密码 admin/admin

 


docker-registry-web 角色管理:

默认用户admin/admin有如下角色: UI_ADMIN、UI_USER、UI_DELETE、read-all、write-all

可以删除或修改UI_ADMIN和UI_USER,这两个角色用来指定角色允许admin和user访问UI系统。

  UI_USER角色允许查询镜像仓库。

  UI_ADMIN角色相比UI_USER角色,允许创建、删除和修改镜像仓库。

  UI_DELETE角色允许基于ACL策略删除镜像

6,拉取私有仓库镜像:

编辑:/etc/docker/daemon.json 没有就创建一个

加入私服地址:"insecure-registries": ["192.168.5.16:5000"]

  1. {
  2. "registry-mirrors": ["https://registry.cn-hangzhou.aliyuncs.com"],
  3. "insecure-registries": ["192.168.5.16:5000"]
  4. }

重新加载:systemctl daemon-reload

重启docker:systemctl restart docker

7, 为registry 生成用户名和密码文件

执行:

docker run  --entrypoint htpasswd registry -Bbn  admin  admin > /securitit/registry/auth/htpasswd

报错解决:

 安装依赖:

  1. yum -y install httpd
  2. htpasswd -Bbn admin admin > /securitit/registry/auth/htpasswd

删除并重启容器:

  1. docker run -d -p 5000:5000 --restart=always --name registry-srv \
  2. -v /securitit/registry/conf/registry-srv.yml:/etc/docker/registry/config.yml \
  3. -v /securitit/registry/data/registry:/var/lib/registry \
  4. -v /securitit/registry/auth/auth.cert:/etc/docker/registry/auth.cert \
  5. -e "REGISTRY_AUTH=htpasswd" \
  6. -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
  7. -e REGISTRY_AUTH_HTPASSWD_PATH=/securitit/registry/auth/htpasswd \
  8. registry

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/95768
推荐阅读
相关标签
  

闽ICP备14008679号