開啟刪除功能
從registry容器里面將/etc/docker/registry/config.yml復(fù)制出來狼荞。
docker cp registry:/etc/docker/registry/config.yml .1
默認(rèn)config.yml內(nèi)容如下:
version: 0.1
log:
fields:
service: registry
storage:
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /var/lib/registry
http:
addr: :5000
headers:
X-Content-Type-Options: [nosniff]
health:
storagedriver:
enabled: true
interval: 10s
threshold: 3123456789101112131415161718
設(shè)置config.yml醋界,在storage節(jié)點(diǎn)添加delete配置設(shè)置為true心肪。
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: 31234567891011121314151617181920
將修改過的config.yml覆蓋容器里面的谓苟。
docker cp config.yml registry:/etc/docker/registry/config.yml
重啟倉庫容器
docker restart registry
查看鏡像名
curl -s -XGET 172.27.36.8:5000/v2/_catalog | python -mjson.tool
查看鏡像tag
curl -s -XGET 172.27.36.8:5000/v2/test_his_platform_global_api_2022-02-18-02-46/tags/list|python -mjson.tool
{
"name": "test_his_platform_global_api_2022-02-18-02-46",
"tags": [
"latest"
]
}
查看鏡像reversion
ls /var/lib/docker/volumes/78c1937e0a8c810c8e4249d0245b4777ac4e66428519376712d99b811e559758/_data/docker/registry/v2/repositories/test_his_platform_global_api_2022-02-18-02-46/_manifests/revisions/sha256
703c4d81c860a7420749f6666aac348e1b62a07062865dfb91d4c30819483e70
## 或者通過API獲取鏡像digest值
curl -i -sS -H 'Accept: application/vnd.docker.distribution.manifest.v2+json' 'https://172.27.36.8:5000/v2/test_his_platform_global_api_2022-02-18-02-46/manifests/latest'
刪除鏡像:
curl -X DELETE 172.27.36.8:5000/v2/test_his_platform_global_api_2022-02-18-02-46/manifests/sha256:703c4d81c860a7420749f6666aac348e1b62a07062865dfb91d4c30819483e70
垃圾回收:
docker exec -it 9658cbb01b13 registry garbage-collect /etc/docker/registry/config.yml
清除目錄:
rm -rf /var/lib/docker/volumes/78c1937e0a8c810c8e4249d0245b4777ac4e66428519376712d99b811e559758/_data/docker/registry/v2/repositories/test_his_platform_global_api_2022-02-18-02-46
web-ui管理registry:
docker hub 地址:https://hub.docker.com/r/hyper/docker-registry-web
docker pull hyper/docker-registry-web
無身份驗(yàn)證棕叫,帶配置文件
創(chuàng)建配置文件config.yml
(此配置中的任何屬性都可能被環(huán)境變量覆蓋识颊,例如屬性registry.auth.enabled將變?yōu)镽EGISTRY_AUTH_ENABLED)
registry:
# Docker registry url
url: http://registry-srv:5000/v2
# Docker registry fqdn
name: localhost:5000
# To allow image delete, should be false
readonly: false
auth:
# Disable authentication
enabled: false
使用 docker 運(yùn)行
docker run -p 5000:5000 --name registry-srv -d registry:2
docker run -it -p 8083:8080 --name registry-web --link registry-srv -v $(pwd)/config.yml:/conf/config.yml:ro hyper/docker-registry-web
Web UI 將在http://localhost:8083