docker-cleanup-volumes icon indicating copy to clipboard operation
docker-cleanup-volumes copied to clipboard

syntax error when using the file stand lone

Open athom opened this issue 9 years ago • 10 comments

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

athom avatar Apr 29 '15 08:04 athom

++ 1 and

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

diezcode avatar Apr 29 '15 08:04 diezcode

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

allvolumes+="${bmv}"

diezcode avatar Apr 29 '15 10:04 diezcode

im sure the author would accept a PR ;)

derek-adair avatar Apr 29 '15 13:04 derek-adair

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

docker ps -a |  awk -F" " 'NR>1 {print $1}' | xargs docker rm -v

athom avatar Apr 29 '15 13:04 athom

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

diezcode avatar Apr 29 '15 14:04 diezcode

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

athom avatar Apr 29 '15 14:04 athom

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

athom avatar Apr 29 '15 14:04 athom

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 :)

chadoe avatar Apr 29 '15 15:04 chadoe

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.

piccaso avatar May 05 '15 23:05 piccaso

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!

dobsiin avatar Jul 13 '15 09:07 dobsiin