Created
May 14, 2020 21:52
-
-
Save bryangruneberg/d7dcfd549cb2e3a0f448d6981121f695 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
declare -a images | |
images[0]="php:7.2-fpm-alpine3.11" | |
images[1]="php:7.3-fpm-alpine3.11" | |
images[2]="php:7.4-fpm-alpine3.11" | |
declare -a desireVersions | |
desireVersions[0]="7.2.31" | |
desireVersions[1]="7.3.18" | |
desireVersions[2]="7.4.6" | |
c=0 | |
for image in "${images[@]}"; do | |
desiredVersion=${desireVersions[$c]} | |
/usr/bin/docker pull $image 1>/dev/null 2>&1 | |
if [ $? -eq 0 ]; then | |
phpVersion=`/usr/bin/docker run $image php-fpm -v | head -n 1 | awk '{print $2}'` | |
if [ "$phpVersion" == "$desiredVersion" ]; then | |
state="updated"; | |
else | |
state="lagging"; | |
fi | |
WORDS="$image - $phpVersion / $desiredVersion [$state]" | |
echo $WORDS | |
else | |
echo "Error pulling: $image" | |
fi | |
c=$c+1 | |
done; | |
unset image; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the only change I would make to this add a
--rm
to the docker command to kill the running container after the command dies.