I'd like to find out if a Docker image with a specific tag exists locally. I'm fine by using a bash script if the Docker client cannot do this natively.
Just to provide some hints for a potential bash script the result of running the docker images
command returns the following:
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
rabbitmq latest e8e654c05c91 5 weeks ago 143.5 MB
busybox latest 8c2e06607696 6 weeks ago 2.433 MB
rabbitmq 3.4.4 a4fbaad9f996 11 weeks ago 131.5 MB
With the help of Vonc's answer above I created the following bash script named
check.sh
:Using it for an existing image and tag will print
exists
, for example:Using it for a non-existing image and tag will print
doesn't exist
, for example:tldr:
By way of demonstration...
success, found image:
failure, missing image:
Reference:
https://docs.docker.com/engine/reference/commandline/image_inspect/