How do I remove a mirror from a private registry?
First, by default, Docker registry is not allowed to remove mirrors and needs to be enabled in the configuration config.yml : vim/etc/docker/registry/config.yml
0.1 log: Fields : service:registrystorage: Delete: true Cache: blobdescriptor:inmemory filesystem: /var/lib/registryhttp: Addr:: headers: X-content-type-Options: [Nosniff]health: Storagedriver: true interval:10s 3
2.3after Registry, must join the head Accept: application/vnd.docker.distribution.manifest.v2+json , otherwise take digest is wrong, this is to prevent the accidental deletion. then, use the API GET /v2/<镜像名>/manifests/<tag> to get the 镜像:Tag corresponding that digest you want to delete .
For example, to delete a myimage:latest mirror, digest the command obtained is:
Curl-i http://10.0.30.6:5000/v2/house/hello/manifests/
Docker-content-digest:sha256:631c0331832510e025cda643a59f92d754c823967176422999b9f87e42b47eb1
Then call the DELETE /v2/<镜像名>/manifests/<digest> API to remove the mirror. Like what:
| curl-x DELETE http://192.168.99.100:5000/v2/myimage/manifests/sha256 : 3a07b4e06c73b2e3924008270c7f3c3c6e3f70d4dbb814ad8bff2697123ca33c |
At this point, the image has been registry removed from the mark and the external access pull is not available. However registry , the local space is not released and needs to wait for garbage collection to be released. While garbage collection cannot be done online, it must be stopped and registry then executed. For example, if registry you run with Compose, the following command is used for garbage collection:
| Docker-compose stopdocker run-it--name gc--rm--volumes-from registry_registry_1 Registry:2 Garbage-collect/etc/regis Try/config.ymldocker-compose start |
registry_registry_1it can be replaced with the actual registry container name and replaced with the /etc/registry/config.yml actual registry profile path.
Image management in the Docker private warehouse registry