-
Notifications
You must be signed in to change notification settings - Fork 18.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support searching tags in a repository on the command line #17238
Comments
+1. For now, I am using curl to get a response json which I have to parse.As tmds suggests, a new command would save some lines of code. |
I think this would depend on the registry / index supporting this, not docker |
I am not sure what you mean by 'docker'. |
@thaJeztah can you add the kind/enhancement label please? |
I wish for this feature in spirit, if maybe not exactly the UX of the proposed command. I'd mostly like to just be able to get lists of tags for images returned in results of Simple listing seems to be there at least since #9015 (incidentally, tag search is brought up among the discussion there too). If more advanced indexing is desired perhaps docker-archive/docker-registry#687 and wherever its breadcrumbs ultimately end are of interest. |
I've written an easy to use command line tool in Python to query DockerHub tags for given repos: It's available as https://github.com/harisekhon/pytools It's simple to use with various command line switches, but most basically:
and there is a ready-to-run docker image on DockerHub:
If you want to use the output embedded as part of scripts then just use
|
Friendly ping. Any updates on this? |
Maybe adding new |
I think even a --tag=1.2.3 or the ability to pass a tag on the image argument would be useful. Specifically for build systems that want to have internal logic to prevent pushed tags being overwritten (a la |
I remember looking for this a few years ago, when I first started learning about Docker. I still find myself looking for this functionality on a regular basis. There are multiple StackOverflow posts requesting for this functionality, and a plethora of obscure shell scripts that hit the registry directly. https://stackoverflow.com/questions/28320134/how-to-list-all-tags-for-a-docker-image-on-a-remote-registry Any chance this could get bumped up @thaJeztah? |
@pcgeek86 I was discussing this a while back, and |
So v1 search uses index.docker.io (https://index.docker.io/v1/search?q=ubuntu), but using a I'll try to get more information on this |
Workaround image_name=python
curl -s https://registry.hub.docker.com/v1/repositories/${image_name}/tags | jq --raw-output ".[].name" Output
|
I have a much better solution @fragmuffin: The fundamental issue with your solution is that it will only show you the 10 latest tags... which might cover most peoples use case, but i needed all of them. I wrote a better description of the problem as a whole over at stackoverflow function docker-tags () {
name=$1
# Initial url
url=https://registry.hub.docker.com/v2/repositories/library/$name/tags/
(
# Keep looping until the variable url is empty
while [ ! -z $url ]; do
# Every iteration of the loop prints out a single dot to show progress as it got through all the pages (this is inline dot)
>&2 echo -n "."
# Curl the url and pipe the output to python, python will parse the JSON and print the very first line as the next url (it will leave it blank if there is no more pages)
# then continue to loop over the results extracting only the name; all will be stored in a variable called content
content=$(curl -s $url | python -c 'import sys, json; data = json.load(sys.stdin); print(data.get("next", "") or ""); print("\n".join([x["name"] for x in data["results"]]))')
# Lets get the first line of content which contains the next url for the loop to continue
url=$(echo "$content" | head -n 1)
# Print the content without the first line (yes +2 is counter intuitive)
echo "$content" | tail -n +2
done;
# Finally break the line of dots
>&2 echo
) | sort --version-sort | uniq;
} And simply call it: Sample output: $ docker-tags redis
..............
2
2.6
2.6.17
2.8
--trunc----
32bit
alpine
latest
nanoserver
windowsservercore |
That's weird, when I run it in an |
FYI @fragmuffin if you just pass |
@dsifford : neat! 👍, I updated my comment with your good advice ;) |
@thaJeztah feel free to close this. |
@tmds is there now a supported way to do this via the |
I'd also appreciate if there's a native way of doing this through the docker CLI |
@kingbuzzman thanks for your python scripting, here a slightly modified version for a little more flexibility:
And simply call it: |
Such a command should search the registry for image tags. The command should allow to filter the tags using wildcards.
e.g.
The text was updated successfully, but these errors were encountered: