In a compose file, how can I create a volume that is bound to some host path,
using the top-level volumes
key?
Basically, I have this:
services:
foo:
volumes:
- type: bind
source: /host/path
target: /container/path
And I want to turn it into this:
services:
foo:
volumes:
- type: volume
source: host-path
target: /container/path
volumes:
host-path:
driver: ???
driver_opts: ???
The documentation for the volumes
service key states:
If the mount is a host path and is only used by a single service,
it MAY be declared as part of the service definition
instead of the top-levelvolumes
key.To reuse a volume across multiple services,
a named volume MUST be declared in the top-level volumes key.
Which implies the top-level volumes
key supports creating a bind volume.
However, the top-level volumes
key documentation doesn’t say anything
about this. It merely states:
Default and available [driver] values are platform specific.
And searching a bit, I couldn’t find which drivers are available for my
platform. Even less how to configure them.