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.
Related
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.
Is it possible to list, or search, private Docker repositories on the online version of Docker Hub, from command line, if you've logged in with an access token? I assume curl commands won't work because you can't log in to the web interface with an access token (and this has been my experience trying various curl commands on Docker), can you use the web API somehow?
I have tried various curl and API based solutions (e.g. How to get a list of images on docker registry v2) but they're mostly geared at private registries, not private repos on Docker Hub
Ideally I'd like to be able to list and/or search for repositories within that user (i.e. public and private, assuming I have an access token that allows me to pull those private repos)
This requires custom tooling just for Docker Hub, which exists as the experimental hub-tool. It's not built into other tools because the repository listing API in registries isn't limited to a user or organization. And the API that queries for all repositories is disabled on most SaaS registries because of scaling, privacy, and security reasons. With hub-tool, the command for that looks like:
$ hub-tool repo ls $user_or_org --format json
as well as tags within each repo
This is a lot easier. It's available from registry APIs, and Hub specific APIs. With hub-tool, that's:
$ hub-tool tag ls $org/$repo --format json
(In each of these, I'm using json formatting assuming you want to script the output.)
Other tools work on any registry, including Google's crane, RedHat's skopeo, and my own regclient.
$ crane ls $repo
$ skopeo list-tags docker://$reppo
$ regctl tag ls $repo
Each of these has different ways to login with your PAT.
$ hub-tool login
$ crane auth login $registry
$ skopeo login $registry
$ regctl registry login $registry
With curl, you need to login to get a token using your username and PAT there. This is all Hub specific, so I'd recommend using one of the above tools instead of curl for portability to other registries:
$ cat ./manifest-v2-auth.sh
#!/bin/sh
ref="${1:-library/ubuntu:latest}"
sha="${ref#*#}"
if [ "$sha" = "$ref" ]; then
sha=""
fi
wosha="${ref%%#*}"
repo="${wosha%:*}"
tag="${wosha##*:}"
if [ "$tag" = "$wosha" ]; then
tag="latest"
fi
token=$(curl -s "https://auth.docker.io/token?service=registry.docker.io&scope=repository:${repo}:pull" \
-u "$username:$user_pat" \
| jq -r '.token')
curl -H "Authorization: Bearer $token" \
-s "https://registry-1.docker.io/v2/${repo}/tags/list" | jq .
I am trying to upload files to Sonatype Nexus, using their API :
curl -v -u admin:admin123 \
--upload-file pom.xml \
http://localhost:8081/repository/maven-releases/org/foo/1.0/foo-1.0.pom
This works like a charm with curl runs from Ubuntu based container.
However, it does not work well with Alpine based container. Indeed, the file URL is created, but the uploaded file is empty ( 0 bytes ) .
is curl syntax different from platform to another?
If so, what's the right syntax with Alpine to call curl with --upload-file option ?
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
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>