搭建docker私有仓库
1.创建仓库镜像存放路径
mkdir -p /opt/registry/registry
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
3.编写配置文件
vim /opt/registry/config.yml
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
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