yum install -y docker-distribution
#vim /etc/docker-distribution/registry/config.yml
version: 0.1
log:
  fields:
    service: registry
storage:
    delete:
        enabled: true
    cache:
        layerinfo: inmemory
    filesystem:
        rootdirectory: /data/registry
http:
    addr: 127.0.0.1:5000
    host: https://dj.repo
    tls:
        certificate: /etc/docker-distribution/registry/ssl/registry.crt
        key: /etc/docker-distribution/registry/ssl/registry.key
mkdir -p /etc/docker-distribution/registry/ssl && cd /etc/docker-distribution/registry/ssl

openssl req -x509 -nodes -days 3650 -sha256 -newkey rsa:4096 -keyout registry.key -out registry.crt
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:
Locality Name (eg, city) [Default City]:
Organization Name (eg, company) [Default Company Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:dj.repo
Email Address []:
openssl x509 -in registry.crt -out /etc/pki/ca-trust/source/anchors/registry.pem -outform PEM
update-ca-trust
systemctl enable docker-distribution
systemctl start docker-distribution
#vim /etc/docker/daemon.json
{
  "graph": "/data/docker",
  "insecure-registries": ["dj.repo"],
  "registry-mirrors": [
    "https://docker.mirrors.ustc.edu.cn",
    "https://hub-mirror.c.163.com",
    "https://mirror.baidubce.com",
    "https://registry.hub.docker.com",
    "https://docker.io"
  ]
}

systemctl daemon-reload && systemctl restart docker
docker run --entrypoint htpasswd registry:2.7.0 -Bbn admin 123456 > /etc/docker-distribution/registry/auth/htpasswd
docker pull nginx:latest
docker tag nginx:latest dj.repo/nginx:latest
docker push dj.repo/nginx:latest

curl -X GET -k https://dj.repo/v2/_catalog
curl -X GET -k https://dj.repo/v2/nginx/tags/list
curl -X GET -k https://dj.repo/v2/nginx/manifests/latest

curl --header "Accept: application/vnd.docker.distribution.manifest.v2+json" -I -X GET -k https://dj.repo/v2/nginx/manifests/latest
curl -X DELETE -k https://dj.repo/v2/nginx/manifests/sha256:13e45

https://github.com/burnettk/delete-docker-registry-image

如果觉得我的文章对你有用,请随意赞赏