1

Docker toolbox 1.9.1 on Windows 7 platform

The data container I created doesn't have volumes when I use docker inspect command.

$ sudo mkdir /abc
$ docker run -d --name data -v /abc:/hostabc busybox true
$ docker inspect --format "{{ .Config.Volumes }}" data
map[]

I also tried this in 1.7.1, it shows like below

$ docker inspect --format "{{ .Volumes }}" data   # in 1.7.1 it is Volumes directly
map[/hostabc:/abc]

Anything I did wrong to create the data container ?

Or there are other place to check the volumes in data container.

Larry Cai
  • 55,923
  • 34
  • 110
  • 156

1 Answers1

2

Try instead

docker inspect -f '{{ (index .Mounts 0).Source }}' containerid

If you have multiple sharing, then simple use range like below

docker inspect -f '{{range $k := .Mounts}}{{println $k.Source }}{{end}}' containerid

As I mentioned here, that changed since docker 1.8

Note: the PR 45 raised by the OP is now merged with directives like:

version=`$docker -v 2>&1 | awk -F'[ .]' '{printf "%2.f%02.f%02.f",$3,$4,$5}'`

# echo $version

if [ $version -gt 10800 ]; then
    echo "docker version 1.8+"
    volumes=`$docker inspect --format='{{range $k := .Mounts}}{{println $k.Destination}}{{end}}' "$container" |  grep -v -E "^$"`
else
    echo "docker version <1.8"
    volumes=`$docker inspect --format='{{range $k,$v := .Volumes}}{{println $k}}{{end}}' "$container" |  grep -v -E "^$"`
fi
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250