From 865395962885301de5fa54576c381e0df913d34f Mon Sep 17 00:00:00 2001 From: buyua9 Date: Tue, 7 Apr 2026 21:40:53 +0800 Subject: [PATCH] docs: explain named bind mounts with driver_opts --- content/includes/compose/volumes.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/content/includes/compose/volumes.md b/content/includes/compose/volumes.md index 20a279370ea7..4d40ec641cf1 100644 --- a/content/includes/compose/volumes.md +++ b/content/includes/compose/volumes.md @@ -1 +1,15 @@ -Volumes are persistent data stores implemented by the container engine. Compose offers a neutral way for services to mount volumes, and configuration parameters to allocate them to infrastructure. The top-level `volumes` declaration lets you configure named volumes that can be reused across multiple services. +Volumes are persistent data stores implemented by the container engine. Compose offers a neutral way for services to mount volumes, and configuration parameters to allocate them to infrastructure. The top-level `volumes` declaration lets you configure named volumes that can be reused across multiple services. + +If you want a named bind mount, use the `local` driver with `driver_opts`. This pattern gives a Compose volume a stable name while mapping it to a specific host path: + +```yaml +volumes: + app-data: + driver: local + driver_opts: + type: none + o: bind + device: /srv/app-data +``` + +The `type`, `o`, and `device` keys are passed through to the local driver. For a one-off host-path mount on a single service, see [bind mounts](/manuals/engine/storage/bind-mounts.md).