chadoe / docker-cleanup-volumes

Shellscript to delete orphaned docker volumes
https://registry.hub.docker.com/u/martin/docker-cleanup-volumes/
MIT License
1.44k stars 198 forks source link

syntax error when using the file stand lone #7

Open athom opened 9 years ago

athom commented 9 years ago

docker@boot2docker:~$ sh docker-cleanup-volumes.sh docker-cleanup-volumes.sh: line 10: syntax error: unexpected "(" docker@boot2docker:~$

diezcode commented 9 years ago

++ 1 and

cleanup.sh: 3: set: Illegal option -o pipefail

diezcode commented 9 years ago

Error HERE allvolumes+="${vid##*/}"

allvolumes+="${bmv}"

derek-adair commented 9 years ago

im sure the author would accept a PR ;)

athom commented 9 years ago

finally I solve my problem using such single command line :P

docker ps -a |  awk -F" " 'NR>1 {print $1}' | xargs docker rm -v
diezcode commented 9 years ago

this command clean up your volumes? without removing the active or used volumes?

athom commented 9 years ago

sweep all volumes, i am afraid that the active ones are removed too. just my special case

athom commented 9 years ago

you might want this tool, maybe better than the shell script.

chadoe commented 9 years ago

Hi, docker-cleanup-volumes.sh is a bash script, boot2docker does not have bash installed by default so you either have to install bash on it or use the docker image for this script. Also @derek-adair is correct, PR's are welcome :)

piccaso commented 9 years ago

boot2docker comes with bash (mingw) but its old...

$ echo $BASH_VERSION
3.1.23(6)-release

not sure if backporting makes sense, but the dockerized version works fine if you ssh into the VM. run Boot2Docker Start an then:

boot2docker ssh
# wait until connection is established...
docker run -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker:/var/lib/docker --rm martin/docker-cleanup-volumes --dry-run

Btw: to paste the docker run ... line use the mouse/context menu, keyboard shortcuts dont work here.

dobsiin commented 9 years ago

there is some error when running without --dry-run option:

[vagrant@devenv docker-cleanup-volumes]$ sudo sh docker-cleanup-volumes.sh docker-cleanup-volumes.sh: line 61: $1: unbound variable

commented # the lines of the --dry-run option and this script works just fine!