Skip to content
This repository has been archived by the owner on Jun 11, 2019. It is now read-only.

Commit

Permalink
use "docker volume" subcommand when using docker 1.9+
Browse files Browse the repository at this point in the history
`docker-cleanup-volumes.sh` doesn't remove volumes properly, since
docker introduced the "volume" subcommand in 1.9.0.

This patch detects the docker version, and runs either
`docker-cleanup-volumes.sh` or `docker volume rm` accordingly.

Fixes #24
  • Loading branch information
Marc Fournier committed May 24, 2016
1 parent 3657a3f commit 3bf09da
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,17 @@ do
if [ $DEBUG ]; then echo DEBUG: Starting loop; fi

# Cleanup unused volumes
echo "=> Removing unused volumes"
/docker-cleanup-volumes.sh

if [[ $(docker version --format '{{(index .Server.Version)}}' | grep -E '^[01]\.[012345678]\.') ]]; then
echo "=> Removing unused volumes using 'docker-cleanup-volumes.sh' script"
/docker-cleanup-volumes.sh
else
echo "=> Removing unused volumes using native 'docker volume' command"
for volume in $(docker volume ls -qf dangling=true); do
echo "Deleting ${volume}"
docker volume rm "${volume}"
done
fi

IFS='
'
Expand Down

0 comments on commit 3bf09da

Please sign in to comment.