Search code examples
dockershellartifactory

Using multiple Artifactory images for scan one at a time in a loop


I have a text file contains of images from Artifactory. I have a shell script to run blackduck scan on those images in a loop but I am getting errors like invalid reference format.

#!/usr/bin/sh
input="dockerimagesURL.txt"
while read dockerimagesURL
do
docker pull "$dockerimagesURL"
DockerImageID=$(docker images "$dockerimagesURL" --format '{{.ID}}')
sudo -S java -jar /home/dxc/Desktop/synopsis-detect-7.11.0/synopsys-detect-7.11.0.jar -- scan command continued.
done < $1

dockerimagesURL.txt file contains:

buildimages-docker-local.artifactory.com/docker-registry1:tag
buildimages-docker-local.artifactory.com/docker-registry2:tag
buildimages-docker-local.artifactory.com/docker-registry3:tag
buildimages-docker-local.artifactory.com/docker-registry4:tag

The above script is failing for multiple reasons: Invalid reference format

docker pull -- not happening


Solution

  • Assuming your full error message is

    'docker-registry1:tag' is not a valid repository/tag: invalid reference format

    'tag' is a placeholder. Replace it by a tag that really exists, e.g. 'latest' (the default).

    buildimages-docker-local.artifactory.com/docker-registry1:latest
    

    The error could still exist after that change if the repository is not valid/cannot be found!