Last active
May 24, 2021 18:44
-
-
Save rjchicago/435222ecd2621c816e61c85634c3c4dc to your computer and use it in GitHub Desktop.
We've encountered errors where either we hit the Docker Hub rate limit, or an image tag has been overwritten and therefor SHA's do not match. This script will loop through images currently in use and attempt a Docker pull and print out any errors.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# loop through services and get names | |
for SERVICE in $(docker service ls --format "{{.Name}}"); do | |
# get the full image:tag@sha used by the service | |
IMAGE=$(docker service inspect $SERVICE --format "{{.Spec.TaskTemplate.ContainerSpec.Image}}") | |
# try image pull and capture error for printing | |
ERROR="$(docker pull -q $IMAGE 2>&1 > /dev/null)" | |
if [[ ! -z $ERROR ]]; then | |
printf "$SERVICE: $IMAGE\n\t$ERROR\n" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment