Skip to content

Commit 36fad25

Browse files
committed
Implement volumes bind.create_host_path option
The `type:bind` volume option `create_host_path` is currently unsupported in `podman-compose`. This prevents users from disabling the automatic creation of host source directories, creating an incompatibility with `docker-compose` functionality. Refer to the relevant `docker-compose` documentation: https://docs.docker.com/reference/compose-file/services/#volumes This commit implements the `create_host_path` option to: - Achieve better alignment with `docker-compose` behavior - Provide control over host directory creation Signed-off-by: Monika Kairaityte <[email protected]>
1 parent af7346b commit 36fad25

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Implemented volumes bind `create_host_path` option.

podman_compose.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,12 @@ async def assert_volume(compose: PodmanCompose, mount_dict: dict[str, Any]) -> N
405405
mount_src = mount_dict["source"]
406406
mount_src = os.path.realpath(os.path.join(basedir, os.path.expanduser(mount_src)))
407407
if not os.path.exists(mount_src):
408+
bind_opts = mount_dict.get("bind", {})
409+
if "create_host_path" in bind_opts and not bind_opts["create_host_path"]:
410+
raise ValueError(
411+
"invalid mount config for type 'bind': bind source path does not exist: "
412+
f"{mount_src}"
413+
)
408414
try:
409415
os.makedirs(mount_src, exist_ok=True)
410416
except OSError:

0 commit comments

Comments
 (0)