Docker private trusted registry - docker

I want to delete images in docker private trusted registry.How we can see the available images and how we can delete the older images ?
I'm using registry:2
Thanks in advance.

From issue 1529, you can see your images with:
curl -k -u 'docker:sdf' -X GET https://localhost:5000/v2/_catalog
For each image, you can list its tags:
curl -k -u 'docker:sdf' -X GET https://localhost:5000/v2/bkf/ebbg/tags/list
Finally, for a tag, you can query its manifest:
curl -k -I -H Accept:\* https://<some_url_or_ip>:5000/v2/<image_name>/manifests/<tag_name>
(Steven Iveson)
Use the value of either of these headers (including the sha256: part if present) - they should be the same:
Docker-Content-Digest
Etag
And you need the manifest to delete an image
DELETE /v2/<name>/manifests/<reference>
curl -k -v -u 'docker:sdf' -X DELETE https://localhost:5000/v2/<name>/manifests/<reference>

Related

Is there a way to get tags of a docker image on github container registry (ghcr.io) via curl or gh command?

Is there a way to get tags of a docker image on github container registry via curl or gh command?
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GH_TOKEN}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/${ORG}/packages/container/${CONTAINER_IMG}
I have tried above but it does not give me docker tags for the iamge.
I am expecting to get the docker tags of ghcr.io containers.

How to get the digest of image with specific tag by using Docker repository API from Docker Hub

I am going to get the digest of image with specific tag on Docker Hub.
There are 3 images with different tags on docker Hub.
Could you provide the curl & GET command example for getting the image digest with specific tag on Docker Hub?
Thank you.
This should work fine:
Can I get an image digest without downloading the image?
docker inspect --format='{{index .RepoDigests 0}}' dockerHubRepo/dockerImageName:tag
Or (cf the above link) :
curl -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
-H "Authorization: Basic ${username_password_base64}" \
'https://auth.docker.io/token?service=registry.docker.io&scope=repository:dockerHubRepo/dockerImageName:tag:pull'

Docker exec. How to use shell-commands in container without entering?

Can someone explain me, how can I use sh-commands inside container without enter that container?
I use a shell script at my host. I want this shell-script to enter one of my container and then curl post to another container through overall network. So, my problem is that when i tring to do something like:
docker exec -ti nodejs sh "curl -X POST \
http://tgbot:3017/deploy \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'cache-control: no-cache' \
-d 'message=Prod has been updated!'"
I have in console:
sh: 0: Can't open curl -X POST http://tgbot:3017/ -H 'Content-Type: application/x-www-form-urlencoded' -H 'cache-control: no-cache' -d 'message=Prod has been updated!'
failed to resize tty, using default size
Or mayby I can curl into docker network right from host somehow?
You can just use Docker exec command on the host machine.
docker exec -it <container name> <command>

List Repository names on Docker Hub

Is there any docker command to only list the names of repositories in docker hub registry?
I didn't find any on docker.io platform.
It's not supported by default, but you can make your own script that contains multiple function in order to list repo names as well as the images within your acccount.
It can be a simple Bash Script or can embedded to your app as a tool to search repos.
Get your authToken by login to dockerHub
Using the authToken you can invoke repo listing under your account.
AuthToken=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${username}'", "password": "'${password}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
curl -s -H "Authorization: JWT $AuthToken" https://hub.docker.com/v2/repositories/${username}/?page_size=100 | jq -r '.results|.[]|.name'
I refer to this script from github.

How to execute "docker checkpoint create container_id checkpoint_id" using curl?

At the moment of writing, docker checkpoint feature is still in experimental phase so there is no official (HTTP) API documentation. Nonetheless, there is an endpoint on the docker daemon that can accept an HTTP request, as it is the one that docker cli uses.
Based on the related docker source code it should be something like
sudo curl -X POST --unix-socket /var/run/docker.sock http://localhost/v1.32/containers/20fb4f16ff10/checkpoints
but this does not work. Any ideas what I may be missing?
The create options is missing.
curl --unix-socket /var/run/docker.sock \
-H "Content-Type: application/json" \
-d '{"CheckpointID": "noting"}' \
-X POST http:/v1.32/containers/20fb4f16ff10/checkpoints

Resources