1.创建仓库镜像存放路径 登录后复制 mkdir -p /opt/registry/registry 1. 2.生成帐号密码 登录后复制 # 安装密码生成命令htpasswd ## centos yum -y install httpd-tools ## ubuntu/debian/deepin apt install apache2-utils # 生成密钥文件 touch /opt/registry/passwd htpasswd -Bbn username password > /opt/registry/passwd 1.2.3.4.5.6.7.8.9. 3.编写配置文件 登录后复制 vim /opt/registry/config.yml 1. 登录后复制 version: 0.1 log: fields: service: registry storage: cache: blobdescriptor: inmemory filesystem: rootdirectory: /var/lib/registry delete: enabled: true 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. 4.创建私有镜像仓库 登录后复制 docker run -d -p 5000:5000 \ --restart=always \ --name registry \ -v /opt/registry/passwd:/etc/registry/auth/passwd \ -v /opt/registry/config.yml:/etc/docker/registry/config.yml \ -v //opt/registry/registry:/var/lib/registry \ -e "REGISTRY_AUTH=htpasswd" \ -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \ -e "REGISTRY_AUTH_HTPASSWD_PATH=/etc/registry/auth/passwd" \ registry:latest 1.2.3.4.5.6.7.8.9.10. 原创作者: navysummer 转载于: https://blog.51cto.com/navysummer/11783907