One article to build a local mirror warehouse
Pull the registry image
docker pull registry:2
Run the registry container
Method 1: No persistence
docker run -d -p 5000:5000 --restart=always --name=registry registry:2
Method 2: Add persistence to the initialization configuration file
# Create a data volume for mounting
docker create volume registryvolume
docker run -d -p 5000:5000 --restart=always --name=registry -v registryvolume:/etc/docker/registry registry:2
Push image
docker push ubuntu:22.04
All endpoints supported by v2
All endpoints supported by v2
Method | Path | Entity | Description |
---|---|---|---|
GET | /V2/ | Base | Check if registry/v2 is supported |
GET | /v2/_catalog | Catalog | View a list of all mirror repositories |
GET | /v2/<repository_name>/tags/list | Tags | View all image tags in the repository |
GET | /v2/<repository_name>/manifests/ |
Manifests | Get information pointed to by summary or tag |
POST | /v2/<repository_name>/manifests/ |
Manifests | Upload information pointed to by abstracts or tags |
DELETE | /v2/<repository_name>/manifests/ |
Manifests | Delete the information pointed to by the summary |
DELETE | /v2/<repository_name>/blobs/ |
Blob | Get the blob pointed to by digest |
DELETE | /v2/<repository_name>/blobs/ |
Blob | Delete the blob pointed to by digest |
Query repository
curl -X GET http://localhost:5000/v2/_catalog # View all repositories
curl -X GET http://localhost:5000/v2/_catalog?n=1&last=ImageName # n is the number of each page, last is the last image name on the page
Get the manifests for a specific image
curl -H "Accept: application/.v2+json" -I -X GET http://localhost:5000/v2/ubuntu/manifests/22.04
If you get the v1 version information and delete the image at this time, it will report 404 not found.
Get the v2 version information as shown below
Etag is an Entity object and HTTP response header that provides a unique identifier for a resource. It is usually used in caching and verification mechanisms to ensure that client resources are up to date.
Blob is also an Entity object, used to store image layers or other data. The sha value of the blob, used for verification and deduplication.
Delete specific images based on digest
curl -I -X DELETE http://localhost:5000/v2/ubuntu/manifests/sha256:34782402df238275b0bd100009b1d31c512d96392872bae234e1800f3452e33d
trigger garbage collection
Trigger garbage collection and delete blobs based on deleted manifests information
docker exec -it registry /bin/registry garbage-collect /etc/docker/registry/