1. 拉取仓库
docker pull registry
2. 安装密码生成工具
sudo apt-get install apache2-utils
3. 生成用户名和密码
htpasswd -Bc /etc/docker/registry/passwords dzq
4. 启动仓库
docker run -d -p 5000:5000  --restart=always --name registry \
     -e REGISTRY_AUTH=htpasswd \
     -e REGISTRY_AUTH_HTPASSWD_REALM=Registry \
     -e REGISTRY_AUTH_HTPASSWD_PATH=/etc/docker/registry/passwords \
     -v /etc/docker/registry/passwords:/etc/docker/registry/passwords \
     registry
前置条件配置/etc/docker/daemon.json
{
  "max-concurrent-downloads": 10,
  "max-concurrent-uploads": 5,
  "default-shm-size": "1G",
  "debug": true,
  "experimental": false,
  "registry-mirrors": [
    "https://x9r52uz5.mirror.aliyuncs.com",
    "https://dockerhub.icu",
    "https://docker.chenby.cn",
    "https://docker.1panel.live",
    "https://docker.awsl9527.cn",
    "https://docker.anyhub.us.kg",
    "https://dhub.kubesre.xyz"
  ],
  "insecure-registries": ["dockerhub:5000"]
}
测试结果:
镜像上传

镜像拉取

这个仓库搭建我花了半天时间, docker login主要卡在401验证错误, 说多了都是泪。。。。。
这个验证错误还是配置不对导致的
    
    










