List or query images and tags used in a Dockerfile.
Pass path to Dockerfile:
dockerfile-image-tags list path/to/Dockerfile
Or pass Dockerfile as input:
cat path/to/Dockerfile | dockerfile-image-tags list
Sample output (JSON):
[{"name":"golang","tag":"1.17.0-alpine"},{"name":"common","tag":"?"},{"name":"common","tag":"?"},{"name":"common","tag":"?"},{"name":"viaductoss/ksops","tag":"v3.0.0"},{"name":"quay.io/argoproj/argocd","tag":"$ARGOCD_VERSION"}]
Use query to return tag for first occurrence of image with specified name:
dockerfile-image-tags query path/to/Dockerfile golang
Pass -n (--occurrence) to return specified
occurrence instead of first occurrence. For example, to return tag for
second FROM golang
:
dockerfile-image-tags query -n 2 path/to/Dockerfile golang
Sample output:
1.17.0-alpine