Skip to main content

Toolbar items

Back to site
Manage

Administration menu

Anonymous

User account actions

  • Log in
  • Create new account
  • Reset your password

User account menu

  • Log in
Home
Hadronrider
How to set up a bare metal home server, run CI/CD using Gitlab, Jenkins and pipelines, make e-toys, automate your home and much more

Main navigation

  • Home
    • HadronRider WWW App
    • Webmail
    • Gitlab
    • Jenkins
    • Mercurial
    • Redmine
    • YouTube channel

Docker registry

Breadcrumb

  • Home

Table of Contents

  1. Setup
  2. Registry API
    1. Querying the registry
    2. Deleting images
By valerio | 1:14 PM BST, Sun September 29, 2024
Back to top

Setup

To launch the service, just run the docker image in a container:

docker run --detach \
   --env REGISTRY_STORAGE_DELETE_ENABLED="true" \
   --publish <A FREE PORT IN THE SYSTEM>:5000 \
   --name registry \
   --restart always \
   --volume <LOCAL DIRECTORY>:/var/lib/registry \
   registry:2.8

REGISTRY_STORAGE_DELETE_ENABLED="true" allows to delete unused/old images. By default, this is disabled.

 

Back to top

Registry API

Official documentation here.

I wrapped them up in a sub-function of HadronRiderWWW with a nice UI (the "failed" blobs are the ones the backend couldn't delete because shared with other images):

Docker registry in HadronriderWWW

Querying the registry

You can look the image "catalog" up by issuing:

GET http://<server ip>:<server port>/v2/_catalog

You can get details of an image and its tags by issuing:

GET http://<server ip>:<server port>/v2/<IMAGE NAME>/tags/list

And finally, you can get the tag's details and list of blobs, i.e. the binary snippets that make an image tag up, by issuing:

GET http://<server ip>:<server port>/v2/<IMAGE NAME>/manifests/<IMAGE TAG>

Deleting images

First, you need an image tag's record and then issue:

DELETE http://<server ip>:<server port>/v2/<IMAGE NAME>/blobs/<BLOB CHECKSUM>

for each of the "blobSum" values in the "fsLayers" field of the tag record.

And finally, delete the image tag in 2 steps.

  1. get the "Docker-Content-Digest" by issuing:
    GET http://<server ip>:<server port>/v2/<IMAGE NAME>/manifests/<IMAGE TAG>
    with 'Accept'='application/vnd.docker.distribution.manifest.v2+json' in the header
     
  2. then with the value of 'Docker-Content-Digest' from the headers of the previous query's response as "image digest":
    DELETE http://<server ip>:<server port>/v2/<IMAGE NAME>/manifests/<IMAGE DIGEST>

Note that some blobs maybe shared with other images so an attempt to delete them will return an HTTP error you can safely ignore.

Back to top
  • Log in or register to post comments

Comments

Powered by Drupal

Copyright © 2024 Company Name - All rights reserved

Developed & Designed by Valerio Canova