docker compose搭建docker私有仓库 docker-compose快速搭建docker私有仓库的步骤
勇者神龟 人气:0创建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看到如下页面即代表访问成功
点击btowse repositories会弹出用户名密码输入框,输入上面创建的用户名密码即可查看仓库中所有的镜像
加载全部内容