Question: The official Docker documentation mentions that I need to run `docker rm -v containername` to specifically remove a data volume. But what do you do if you already removed all the containers referencing the specific data volume ?

Answer: 
Use command 

```
docker volume ls -qf dangling=true | xargs -r docker volume rm

```

to clear dangling volumes from docker 1.9 and above.
I have docker 1.6.

The python version didn't work for me it was complaining docker version mismatch. It's amazing, that in times like this, nothing beats the good old way of doing things. 

```
volpurge() {
    if [ $(id -u) -ne 0 ];then
        echo "please run as root"
        return 1
    fi
    BASEDIR=/var/lib/docker/vfs/dir
    a=$(mktemp)
    b=$(mktemp)
    c=$(mktemp)
    printf "checking docker volumes ... "
    cd $BASEDIR
    ls -1 | sort -u > $a
    cd -
    tot1=$(wc -l < $a)
    echo "found $tot1 total" 
    printf "inspecting volumes used by existing containers ... "
    for x in $(docker ps -qa | sed '1d');do
        docker inspect -f '{{ .Volumes }}' ${x} | tr ' ' '\n' | cut -d':' -f2 | tr -d ']' | grep $BASEDIR >> $b
    done
    sed -i 's/\/var\/lib\/docker\/vfs\/dir\///g' $b
    sort -u $b > $c
    mv -f $c $b
    tot2=$(wc -l < $b)
    echo "found $tot2 total" 

    if [ "$tot1" -gt "$tot2" ];then
        comm -3 $a $b > $c
        tot3=$(wc -l < $c)
        echo "purging $tot3 dangling volumes ... "
        read -p "proceed? [y/n]" decision
        if [ "$decision" = "y" ];then
            while read d;do
                printf "."
                rm -rf ${BASEDIR}/$d
            done < $c
        else
            echo "OK. Please examine this manually"
            cat $c
        fi
    else
        echo "nothing to purge"
    fi
    rm -f $a $b $c
}

```

---

Simply add the 'volpurge()' function declaration into your root's .bashrc file. This function must be run as root.