Search code examples
dockervolume

How to list Docker host volumes?


When I run docker volume ls this command shows my normal volumes but not host volumes.

How can I ls that type of volumes?


Solution

  • With a bit of Go template formatting, the bind mounts can be pulled from docker inspect

    docker inspect --format \
      '{{range .Mounts}}{{if eq .Type "bind"}}{{$.Id}} {{.Source}}:{{.Destination}}{{end}}{{end}}' \
      $(docker ps -aq) \
      | grep '.'
    

    I'm not sure how to remove the blank lines in Go, hence the grep. I think it might be docker inspect adding those.