mirror of
https://github.com/containers/podman-compose.git
synced 2025-08-10 14:18:04 +02:00
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 <monika@kibit.lt>
This commit is contained in:
@ -0,0 +1 @@
|
||||
Implemented volumes bind `create_host_path` option.
|
@ -405,6 +405,12 @@ async def assert_volume(compose: PodmanCompose, mount_dict: dict[str, Any]) -> N
|
||||
mount_src = mount_dict["source"]
|
||||
mount_src = os.path.realpath(os.path.join(basedir, os.path.expanduser(mount_src)))
|
||||
if not os.path.exists(mount_src):
|
||||
bind_opts = mount_dict.get("bind", {})
|
||||
if "create_host_path" in bind_opts and not bind_opts["create_host_path"]:
|
||||
raise ValueError(
|
||||
"invalid mount config for type 'bind': bind source path does not exist: "
|
||||
f"{mount_src}"
|
||||
)
|
||||
try:
|
||||
os.makedirs(mount_src, exist_ok=True)
|
||||
except OSError:
|
||||
|
Reference in New Issue
Block a user