Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryangruneberg/d7dcfd549cb2e3a0f448d6981121f695 to your computer and use it in GitHub Desktop.
Save bryangruneberg/d7dcfd549cb2e3a0f448d6981121f695 to your computer and use it in GitHub Desktop.
#!/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;
@seanhamlin
Copy link

the only change I would make to this add a --rm to the docker command to kill the running container after the command dies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment