Skip to content

Commit 2a99f4e

Browse files
committed
Expand explanation of create_host_path
Signed-off-by: Matthijs van den Bos <[email protected]>
1 parent a8a9d13 commit 2a99f4e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

content/reference/compose-file/services.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,6 +2035,9 @@ The short syntax uses a single string with colon-separated values to specify a v
20352035
> platform it rejects Compose files which use relative host paths with an error. To avoid ambiguities
20362036
> with named volumes, relative paths should always begin with `.` or `..`.
20372037

2038+
> [!NOTE]
2039+
> For bind mounts, short syntax creates a directory at the source path on the host if it doesn't exist. This is for backward compatibility with `docker-compose` legacy. It can be prevented by using long syntax and setting `create_host_path` to `false`.
2040+
20382041
#### Long syntax
20392042

20402043
The long form syntax lets you configure additional fields that can't be
@@ -2048,9 +2051,7 @@ expressed in the short form.
20482051
- `read_only`: Flag to set the volume as read-only.
20492052
- `bind`: Used to configure additional bind options:
20502053
- `propagation`: The propagation mode used for the bind.
2051-
- `create_host_path`: Creates a directory at the source path on host if there is nothing present.
2052-
Compose does nothing if there is something present at the path. This is automatically implied by short syntax
2053-
for backward compatibility with `docker-compose` legacy.
2054+
- `create_host_path`: Creates a directory at the source path on the host if it doesn't exist. Defaults to `true`.
20542055
- `selinux`: The SELinux re-labeling option `z` (shared) or `Z` (private)
20552056
- `volume`: Configures additional volume options:
20562057
- `nocopy`: Flag to disable copying of data from a container when a volume is created.

0 commit comments

Comments
 (0)