創(chuàng)建docker-compose.yml并填入如下內(nèi)容
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證書,此證書可以自己生成也可以去阿里云等網(wǎng)站申請,由于是私有倉庫,筆者建議采用私有證書
復(fù)制此文件,并執(zhí)行docker-compose up命令
創(chuàng)建登錄用戶和密碼
docker run --entrypoint htpasswd registry:2 -Bbn username password >> /home/registry/auth/htpasswd
打開瀏覽器,輸入http://本機(jī)ip:5001看到如下頁面即代表訪問成功
點擊btowse repositories會彈出用戶名密碼輸入框,輸入上面創(chuàng)建的用戶名密碼即可查看倉庫中所有的鏡像
到此這篇關(guān)于docker-compose快速搭建docker私有倉庫的步驟的文章就介紹到這了,更多相關(guān)docker compose搭建docker私有倉庫內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!