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

#9 Remove all outdated containers when an image got updated

parent 817bb1e5
No related branches found
No related tags found
No related merge requests found
......@@ -48,6 +48,7 @@ fi
ID=$(docker container ls -q -f name=${COMPOSE_PROJECT_NAME}_l3d)
if [[ "$1" == "update" ]]; then
IMAGEID=$(docker image ls -q registry.lakedrops.com/docker/l3d:php-${PHP_VERSION})
echo "Updating the image ..."
STATUS=$(docker pull registry.lakedrops.com/docker/l3d:php-${PHP_VERSION})
if [[ "$STATUS" == *"Status: Image is up to date"* ]]; then
......@@ -55,10 +56,16 @@ if [[ "$1" == "update" ]]; then
else
echo "Image updated"
if [[ -n "$ID" ]]; then
echo "Removing outdated container ..."
docker stop ${COMPOSE_PROJECT_NAME}_l3d
docker rm ${COMPOSE_PROJECT_NAME}_l3d
ID=
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
fi
fi
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