Skip to content
Snippets Groups Projects
Commit 51ff069f authored by jurgenhaas's avatar jurgenhaas
Browse files

#15 Improve image update script

parent 41570732
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
if [[ -n ${PHP_VERSION} ]]; then
IMAGEID=$(docker image ls -q registry.lakedrops.com/docker/l3d/php-${PHP_VERSION}:${VERSION})
echo "Updating the image ..."
STATUS=$(docker pull registry.lakedrops.com/docker/l3d/php-${PHP_VERSION}:${VERSION})
if [[ "$STATUS" == *"Status: Image is up to date"* ]]; then
echo "Already up to date"
else
echo "Image updated"
NEWIMAGEID=$(docker image ls -q registry.lakedrops.com/docker/l3d/php-${PHP_VERSION}:${VERSION} | head -1)
while true; do
ID=$(docker container ls -q -f ancestor=${IMAGEID})
if [[ -n ${ID} ]]; then
echo "Removing outdated container ..."
docker stop ${ID}
docker rm ${ID}
IMAGEID=$(docker image ls -q registry.lakedrops.com/docker/l3d/php-${PHP_VERSION} | grep --invert-match ${NEWIMAGEID})
if [[ -n ${IMAGEID} ]]; then
while true; do
ID=$(docker container ls -q -f ancestor=${IMAGEID})
if [[ -n ${ID} ]]; then
echo "Removing outdated container ..."
docker stop ${ID}
docker rm ${ID}
else
break
fi
done
echo "Removing outdated image ..."
docker rmi ${IMAGEID}
else
break
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment