Created
June 28, 2018 20:47
-
-
Save DavidPesticcio/314e3e88c9bf71a0729d63119f5ae527 to your computer and use it in GitHub Desktop.
remove images from docker registry v2.4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to delete an image tag/image from docker registry v2.4 | |
1) Re/Start registry with delete option enabled | |
Edit the config.yml | |
storage: | |
delete: | |
enabled: true | |
Or pass the following environment variable to `docker run` | |
REGISTRY_STORAGE_DELETE_ENABLED=true | |
2) Get tags list for repo | |
curl -s GET http://<registry_host:port>/v2/<repo_name>/tags/list | |
3) Get manifest for selected tag | |
curl -sI GET http://<registry_host:port>/v2/<repo_name>/manifests/<tag_name> | |
4) Copy repo digest hash from response header | |
Docker-Content-Digest: <digest_hash> | |
5) Delete manifest (soft delete). This request only marks image tag as deleted and doesn't delete files from file system. If you want to delete data from file system, run this step and go to the next step | |
curl -svIX DELETE http://<registry_host:port>/v2/<repo_name>/manifests/<digest_hash> | |
Note! You must set headers for request - Accept: application/vnd.docker.distribution.manifest.v2+json | |
6) Delete image data from file system | |
Run command from the registry host machine: | |
docker exec -it <registry_container_id or name> bin/registry garbage-collect <path/to/registry/config.yml> | |
Note! Usually, <path_to_registry_config>=/etc/docker/registry/config.yml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment