for-linux
for-linux copied to clipboard
List available tags of image hosted by registry via docker command
- [ ] This is a bug report
- [x] This is a feature request
- [x] I searched existing issues before opening this one
Expected behavior
I found an interesting image (example: eldesh/smlnj
) via docker search ...
I wanted to try out, but when I tried pulling it, it said the tag latest
wasn't found. I was hoping to list available tags from within docker(1)
, but it turned out only possible via an external script (using the registry API), or visiting the registry website.
An alternative I also found was run docker pull -a ...
(and then list the images afterwards) but that tends to use more storage/bandwidth than one might hope.
Actual behavior
I had to volunteer ~2.5 GiB of disk space to run docker pull -a eldesh/smlnj
though I could have used the api or visited the website to obtain a list of tags.
Steps to reproduce the behavior
- Find an interesting image:
docker search smlnj
(in this caseeldesh/smlnj
) - Try to pull it:
docker pull eldesh/smlnj
, but get the following output:
Using default tag: latest
Error response from daemon: manifest for eldesh/smlnj:latest not found
- Try to find way to get list of tags via
docker(1)
, but best option isdocker pull -a eldesh/smlnj
at the cost of extra downloads and disk space.
Output of docker version
:
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.10.3
Git commit: 9ee9f40
Built: Sat Jul 28 16:09:24 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.1-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.10.3
Git commit: 9ee9f40
Built: Sat Jul 28 16:08:49 2018
OS/Arch: linux/amd64
Experimental: false
Output of docker info
:
Containers: 38
Running: 0
Paused: 0
Stopped: 38
Images: 166
Server Version: 18.03.1-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489 (expected: 773c489c9c1b21a6d78b5c538cd395416ec50f88)
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: v0.16.1 (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
seccomp
Profile: default
Kernel Version: 4.14.65-gentoo
Operating System: Gentoo/Linux
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.54GiB
Name: snowcrash
ID: NUVV:J4I2:N2SL:ZEVR:7PMN:QDAX:AUNX:KAXM:5GQB:QZGB:RNWJ:EGFC
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Additional environment details (AWS, VirtualBox, physical, etc.)
+1 This would be really useful. I'd like to pull a tag based off of a specific branch if it exists and if not I'll just pull the :latest
To do that I'd have a script that does something like:
if $(docker tag -r company/product:my_tag); then
docker pull company/product:my_tag
else
docker pull company/product:latest
fi
That being said, I think perhaps this ticket needs to be migrated to docker/cli since this is a cli issue.
You can use docker manifest inspect
to do this.
if docker manifest inspect company/product:my_tag >/dev/null 2>&1; then
# do stuff
fi
Can docker manifest
list tags for an image on the registry? (Without pulling all the images?)
Oh no it can only check the existence of one image / manifest list
Doesn't it also require you to edit a config file and enable experimental mode on any machines that might run this? Definitely I can do that locally but I'm not sure about everywhere else.
@tgaff You can use an environmental variable to set that as of 18.06
with DOCKER_CLI_EXPERIMENTAL
, the feature is still marked as experimental but we heavily use it internally with the environment variable set.
Also it would be great to find the tags pointing to the same image. E.g. I want to identify the tags, which are also pointing to the same image as latest. So I can use that one, and log and add this information to the process, and know later on much better, which docker image was used, even if I want to use always the latest one.
Related use case: https://github.com/docker/cli/issues/836
Related StackOverflow answer: How to pull all alternative tags of a docker image?
Also it would be great to find the tags pointing to the same image. E.g. I want to identify the tags, which are also pointing to the same image as latest.
+1
We deploy images by digest, for stability and repeatability, periodically updating the digest by running docker pull nginx:latest
followed by docker inspect --format='{{index .RepoDigests 0}}' nginx:latest
(then creating a PR if there's any change). Unfortunately, that means we only have the word "latest" and the digest when reviewing the upgrade; being able to retrieve that the image is also tagged "1.19.6" would be excellent in reviewing the upgrade (particularly to see if it's major, minor or patch-level upgrade) and in diagnosing any failures.
If you have Docker Desktop installed, you can use the hub-tool
utility that's currently in preview (still beta, and both UX and name will likely change); https://www.docker.com/blog/docker-hub-experimental-cli-tool/
$ hub-tool tag ls --sort updated nginx
TAG DIGEST STATUS LAST UPDATE LAST PUSHED LAST PULLED SIZE
nginx:stable-alpine-perl sha256:0c85226446a083d92fbf432faee51d12933eafdcf13eb0b7d06fc465368ae908 active 2 weeks ago 2 weeks 3 minutes 124.8MB
nginx:stable-alpine sha256:da3716611fb965f3fda1f3281882baeb2760ca8bb7317f1d22ed45e75570827b active 2 weeks ago 2 weeks 5 minutes 64.99MB
nginx:mainline-alpine-perl sha256:65f87cf0859fc1de79c1346ce9b7b7ecb4abb6042339a6b696fc08309453d74c active 2 weeks ago 2 weeks 21 minutes 126.3MB
nginx:mainline-alpine sha256:55533d629d34a30401be42a186c2d7f6338feb808e42a3b40f40faf3f99b5596 active 2 weeks ago 2 weeks 2 minutes 66.49MB
nginx:alpine-perl sha256:4737b313d0297ec1a570279002be57c4440ba229b6937a9a3e54775823d3f17f active 2 weeks ago 2 weeks 21 minutes 126.3MB
nginx:alpine sha256:50bf829ce093e6a1b5e244a9017bb8679590344332f01f8d1eb947877c9a3694 active 2 weeks ago 2 weeks 2 minutes 66.49MB
nginx:1.19.6-alpine-perl sha256:63a230880775f228250a85db638626f1d5c323bbf4b18014dd2e0e9f616ee746 active 2 weeks ago 2 weeks 21 minutes 126.3MB
nginx:1.19.6-alpine sha256:336994e7a9b771908b905b1c0124e11895780b0e3af50075a2014063b3292bfd active 2 weeks ago 2 weeks 2 minutes 66.49MB
nginx:1.19-alpine-perl sha256:e431b86f520afaf3e800e15b428e969f67eecb34b85bae5c25fbc0bddf519ce2 active 2 weeks ago 2 weeks 21 minutes 126.3MB
nginx:1.19-alpine sha256:50bf829ce093e6a1b5e244a9017bb8679590344332f01f8d1eb947877c9a3694 active 2 weeks ago 2 weeks 2 minutes 66.49MB
nginx:1.18.0-alpine-perl sha256:b2c101d2a7dbe9a3aa31b59a73ae9fb7dcf768502eebc75ffd61345b166271f4 active 2 weeks ago 2 weeks 3 minutes 124.8MB
nginx:1.18.0-alpine sha256:52e7d61873346c887de8258923a52e3f06a2f8e84caa8c9133376acd00c8da13 active 2 weeks ago 2 weeks 5 minutes 64.99MB
nginx:1.18-alpine-perl sha256:b2c101d2a7dbe9a3aa31b59a73ae9fb7dcf768502eebc75ffd61345b166271f4 active 2 weeks ago 2 weeks 3 minutes 124.8MB
nginx:1.18-alpine sha256:a41846b6a41f298784b7dd9925d0b6649794d47244fe01e17b7f9ad8af344494 active 2 weeks ago 2 weeks 5 minutes 64.99MB
nginx:1-alpine-perl sha256:71c78821092dcb3764fae2d1e6d78fc38417f7dc486451125efaa06563165a44 active 2 weeks ago 2 weeks 21 minutes 126.3MB
nginx:1-alpine sha256:d152c79d06eeb7d7acd4041f47b8c71ef93e52b2f6fa70aee4e0fc365bdc475d active 2 weeks ago 2 weeks 2 minutes 66.49MB
nginx:perl sha256:b7d135f454cb7e64cc0189b23dca7c72523689db7245f2bc381782b30c4bbade active 3 weeks ago 3 weeks 9 minutes 506.4MB
nginx:mainline-perl sha256:29934d835af32d2af4156df8676d420e0471234634f42c2a241f62fdd79c9278 active 3 weeks ago 3 weeks 9 minutes 506.4MB
...
Hi,
The "hub-tool" can be used also for Private docker registries , like jFrog docker registry in a company? Or this handles only Docker Hub at https://hub.docker.com/ ?
Thanks in advance