I'd like to know how to list all tags of a Docker image on a remote Docker registry (tutum in our case but I don't suppose it matters) using the CLI (preferred) or curl? Preferably without pulling all versions from the remote registry, I just want to list the tags.
相关问题
- Docker task in Azure devops won't accept "$(pw
- Unable to run mariadb when mount volume
- Unspecified error (0x80004005) while running a Doc
- What would prevent code running in a Docker contai
- How to reload apache in php-apache docker containe
I've managed to get it working using curl:
Note that
image_name
should not contain user details etc. For example if you're pushing image namedtutum.co/username/x
thenimage_name
should bex
.The Docker V2 API requires an OAuth bearer token with the appropriate claims. In my opinion, the official documentation is rather vague on the topic. So that others don't go through the same pain I did, I offer the below
docker-tags
function.The most recent version of
docker-tags
can be found in my GitHubGist : "List Docker Image Tags using bash".The docker-tags function has a dependency on jq. If you're playing with JSON, you likely already have it.
Example
Admittedly,
docker-tags
makes several assumptions. Specifically, the OAuth request parameters are mostly hard coded. A more ambitious implementation would make an unauthenticated request to the registry and derive the OAuth parameters from the unauthenticated response.Building on Yan Foto's answer (the v2 api), I created a simple Python script to list the tags for a given image.
Usage:
Output:
If the JSON parsing tool,
jq
is availableSee CLI utility: https://www.npmjs.com/package/docker-browse
Allows enumeration of tags and images.
docker-browse tags <image>
will list all tags for the image. e.g.docker-browse tags library/alpine
docker-browse images
will list all images in the registry. Not currently available forindex.docker.io
.You may connect it to any registry, including your private one, so long as it supports Docker Registry HTTP API V2
You can use it if your env has no 'jq', = )