podman-compose
podman-compose copied to clipboard
podman-compose does not support windows devices in volumes mapping, incompatible with docker
I am running on Windows 10, using podman-compose 1.0.3. I also tested with 1.0.4 from the repository.
I have a docker-compose.yaml with the following volume mapping:
volumes:
- C:/users/jsparkes/sql_data:/sql_data
When I run podman-compose up
I get an error message:
podman-compose version: 1.0.4
['podman', '--version', '']
using podman version: 4.3.1
Traceback (most recent call last):
File "C:\Users\jsparkes\sql_data\podman_compose.py", line 2862, in <module>
main()
File "C:\Users\jsparkes\sql_data\podman_compose.py", line 2858, in main
podman_compose.run()
File "C:\Users\jsparkes\sql_data\podman_compose.py", line 1383, in run
self._parse_compose_file()
File "C:\Users\jsparkes\sql_data\podman_compose.py", line 1580, in _parse_compose_file
mnt_dict = get_mnt_dict(self, cnt, volume)
File "C:\Users\jsparkes\sql_data\podman_compose.py", line 481, in get_mnt_dict
volume = parse_short_mount(volume, basedir)
File "C:\Users\jsparkes\sql_data\podman_compose.py", line 156, in parse_short_mount
raise ValueError("unknown mount option " + opt)
ValueError: unknown mount option /sql_data
Obviously podman-compose
is interpreting the "C:" as the first part of the volume mapping.
This is strictly a compatability issue with Docker Compose. Docker apparently maps the "C:" into "/mnt/C" before passing it on to docker command. If I manually do that in the file, podman-compose
works as expected.
It would be nice to be exactly compatible with docker here so that I can use the same yaml file.
podman-compose
should transform a volumes mapping starting with "^[a-zA-Z]:" into "/mnt/$char/" before processing it to be compatible with docker compose.
That's never the intention of podman, as podman doesn't have native windows binary, only binary run on WSL. I think if you want that to work, just change it into /mnt/c, approach using unix ways....
As you know, docker has windows client, that's why they can remap it... as podman-compose pure linux python script... welp... I think it's a baggage to add this implementation...
I don't know about at the time of your comment, but Podman and Podman Desktop both run natively on Windows using a WSL backend (the same as Docker and Docker Desktop on Windows)
This should probably be fixed to be consistent with docker-compose on Windows :+1:
Any updates?
colon :
is the delimiter between host path or volume and container and mount options
how I can know
myvol:/cntpath:ro
a:b:c
how can I know that a:
is a drive or a directory followed by colon delimiter?
how can I know that a: is a drive or a directory followed by colon delimiter?
Maybe the same way docker does it. As far as I understand, docker uses different rules for Windows and Linux when parsing paths
- https://forums.docker.com/t/whats-the-correct-way-to-mount-a-volume-on-docker-for-windows/58494/2
# Host: Windows, Container: Linux
# mount new volume "foo"
docker run --rm -it -v "foo:/bar" ubuntu bash
# mount existing directory "\\wsl$\...\home\user\foo"
docker run --rm -it -v "./foo:/bar" ubuntu bash
# mount existing directory "C:\foo"
docker run --rm -it -v "C:\foo:/bar" ubuntu bash
# mount existing directory "C:\foo" in readonly mode
docker run --rm -it -v "C:\foo:/bar:ro" ubuntu bash
docker run --rm -it -v "C:/foo:/bar:ro" ubuntu bash
@flibustier7seas I think with podman windows and new MR, this can be retested?
https://github.com/containers/podman/blob/main/docs/tutorials/podman-for-windows.md#volume-mounting
https://github.com/containers/podman-compose/commit/9a5b43907f95e72d27f2c1b840ec584e38288ad5
https://github.com/containers/podman-compose/issues/704
As the checker for NT/Windows already in place.
@benyaminl Hi! I have tried with the latest version. It seems it doesn't work.
pip install podman-compose --upgrade
# Requirement already satisfied: podman-compose in c:\python312\lib\site-packages (1.0.6)
# Collecting podman-compose
# Using cached podman_compose-1.2.0-py2.py3-none-any.whl.metadata (5.6 kB)
# Requirement already satisfied: pyyaml in c:\python312\lib\site-packages (from podman-compose) (6.0.1)
# Requirement already satisfied: python-dotenv in c:\python312\lib\site-packages (from podman-compose) (1.0.1)
# Using cached podman_compose-1.2.0-py2.py3-none-any.whl (39 kB)
# Installing collected packages: podman-compose
# Attempting uninstall: podman-compose
# Found existing installation: podman-compose 1.0.6
# Uninstalling podman-compose-1.0.6:
# Successfully uninstalled podman-compose-1.0.6
# Successfully installed podman-compose-1.2.0
podman-compose --version
# podman-compose version 1.2.0
# podman.exe version 4.9.3
cat C:\Personal\repos\notes\Docker\podman-compose__example\nginx__compose.yml
# version: "3"
# services:
# smartcat:
# image: nginx:latest
# container_name: my-nginx
# volumes:
# - C:\Personal\repos\notes\Docker\podman-compose__example:/workdir
podman-compose --file C:\Personal\repos\notes\Docker\podman-compose__example\nginx__compose.yml up --detach
# Traceback (most recent call last):
# File "<frozen runpy>", line 198, in _run_module_as_main
# File "<frozen runpy>", line 88, in _run_code
# File "C:\Python312\Scripts\podman-compose.exe\__main__.py", line 7, in <module>
# File "C:\Python312\Lib\site-packages\podman_compose.py", line 3504, in main
# asyncio.run(async_main())
# File "C:\Python312\Lib\asyncio\runners.py", line 194, in run
# return runner.run(main)
# ^^^^^^^^^^^^^^^^
# File "C:\Python312\Lib\asyncio\runners.py", line 118, in run
# return self._loop.run_until_complete(task)
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# File "C:\Python312\Lib\asyncio\base_events.py", line 685, in run_until_complete
# return future.result()
# ^^^^^^^^^^^^^^^
# File "C:\Python312\Lib\site-packages\podman_compose.py", line 3500, in async_main
# await podman_compose.run()
# File "C:\Python312\Lib\site-packages\podman_compose.py", line 1741, in run
# self._parse_compose_file()
# File "C:\Python312\Lib\site-packages\podman_compose.py", line 1980, in _parse_compose_file
# mnt_dict = get_mnt_dict(self, cnt, volume)
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# File "C:\Python312\Lib\site-packages\podman_compose.py", line 521, in get_mnt_dict
# volume = parse_short_mount(volume, basedir)
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# File "C:\Python312\Lib\site-packages\podman_compose.py", line 181, in parse_short_mount
# raise ValueError("unknown mount option " + opt)
# ValueError: unknown mount option /workdir
I think if you want that to work, just change it into /mnt/c, approach using unix ways....
It seems that /mnt/c/...
and /c/...
patterns don't work as well; new directories are being created instead of using the expected directories.
version: "3"
services:
smartcat:
image: nginx:latest
container_name: my-nginx
volumes:
- /mnt/c/Personal/repos/notes/Docker/podman-compose__example:/workdir
version: "3"
services:
smartcat:
image: nginx:latest
container_name: my-nginx
volumes:
- /c/Personal/repos/notes/Docker/podman-compose__example:/workdir
Expected results
The C:\Personal\repos\notes\Docker\podman-compose__example
directory will be used.
Actual results
-
/mnt/c/Personal/repos/notes/Docker/podman-compose__example:/workdir
- a new directory will be created:
C:\mnt\c\Personal\repos\notes\Docker\podman-compose__example
- a new directory will be created:
-
/c/Personal/repos/notes/Docker/podman-compose__example:/workdir
- a new directory will be created
C:\c\Personal\repos\notes\Docker\podman-compose__example
- a new directory will be created