The argument to --format
is a standard go text/template expression. If you want to get the host path corresponding to a particular container path, you could do this:
$ docker inspect -f '{{index .Volumes "/container/path/1"}}' container
/host/path/1
If you want to produce a list of host:container pairs, you could do this:
$ docker inspect -f '{{range $key, $value := .Volumes}}{{printf "%s:%s\n" $key $value}}{{end}}'
Which would get you:
/container/path/1:/host/path/1
/container/path/2:/host/path/2
In this example, we're taking advantage of this syntax:
A pipeline inside an action may initialize a variable to capture the
result. The initialization has syntax
$variable := pipeline
where $variable is the name of the variable. An action that declares a
variable produces no output.
If a "range" action initializes a variable, the variable is set to the
successive elements of the iteration. Also, a "range" may declare two
variables, separated by a comma:
range $index, $element := pipeline
in which case $index and $element are set to the successive values of
the array/slice index or map key and element, respectively. Note that
if there is only one variable, it is assigned the element; this is
opposite to the convention in Go range clauses.