兴国资源网 Design By www.nnzcdc.com

创建docker-compose.yml并填入如下内容

version: '3'
services:
 registry:
 restart: always
 image: registry:2
 ports:
  - 5000:5000
 environment:
  REGISTRY_HTTP_TLS_CERTIFICATE: /certs/registry.crt
  REGISTRY_HTTP_TLS_KEY: /certs/registry.key
  REGISTRY_AUTH: htpasswd
  REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
  REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
 volumes:
  - /home/docker/registry:/var/lib/registry
  - /home/registry/cert:/certs
  - /home/registry/auth:/auth
 registry-ui:
  image: konradkleine/docker-registry-frontend:v2
  restart: always
  environment:
   - ENV_DOCKER_REGISTRY_HOST=registry
   - ENV_DOCKER_REGISTRY_PORT=5000
   - ENV_DOCKER_REGISTRY_USE_SSL=1
  ports:
   - "5001:80"

其中REGISTRY_HTTP_TLS_CERTIFICATE为ssl证书,此证书可以自己生成也可以去阿里云等网站申请,由于是私有仓库,笔者建议采用私有证书

复制此文件,并执行docker-compose up命令

创建登录用户和密码

docker run --entrypoint htpasswd registry:2 -Bbn username password  /home/registry/auth/htpasswd

打开浏览器,输入http://本机ip:5001看到如下页面即代表访问成功

docker-compose快速搭建docker私有仓库的步骤

点击btowse repositories会弹出用户名密码输入框,输入上面创建的用户名密码即可查看仓库中所有的镜像

兴国资源网 Design By www.nnzcdc.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
兴国资源网 Design By www.nnzcdc.com