I know the ID of a Docker image. I would like to list all the references (names) that point to that image (or even if it has no references at all).
Despite docker image
has many filtering capabilities I have not found how to filter the output to restrict it to a single image ID.
Example:
$ docker images --no-trunc --filter=reference=alpine:3.12 '--format={{.ID}} {{printf "%s:%-26s" .Repository .Tag}} {{.CreatedAt}}'
sha256:d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0 alpine:3.12 2020-10-22 04:19:24 +0200 CEST
I expected one of theese commands to work, but they don't:
$ docker images --no-trunc '--format={{.|json}}' sha256:d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0 | wc -l
0
$ docker images --no-trunc '--format={{.|json}}' --filter=ID=sha256:d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0
Error response from daemon: Invalid filter 'id'
I also tried to filter with a custom format, but this gives a empty line for each image which is not matching and this is not what I want.
docker images --no-trunc '--format={{if eq .ID "sha256:d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0"}}{{.|json}}{{end}}'
Note: no, I don't want to use grep
or sed
because I would like to use the full power of --format
to have the output that I need, and those command are not portable widely enough.