containers / containers/podman-compose

Wrong path when extended docker-compose file

Open
#703 1 comment 1 reaction 0 assignees View on GitHub
bug
Dominant language
Python
Stars
6.2k
Forks
622
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
When a docker-compose file extends another one not in the same directory and containing volumes, then the path to the local shared files is wrong.

**To Reproduce**
See test case:
[dc-case.zip](https://github.com/containers/podman-compose/files/11650959/dc-case.zip)
running
- $ docker compose -f base-dc.yaml up
- $ docker compose -f ./extended/extended-dc.yaml up

give the same result: displaying "Hello World"

However, running
- $ sudo /usr/local/bin/podman-compose -f base-dc.yaml up
- $ sudo /usr/local/bin/podman-compose -f extended/extended-dc.yaml up

The first is working perfectly, while the second causes an error as the hello.txt file is not found.

Looking at the generated podman create command, I can see that the volume definition is wrong (the path is taken as is from the extended file, instead of relative from the base file).

**Output**

```
$ sudo /usr/local/bin/podman-compose -f base-dc.yaml up
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.4.1
** excluding: set()
['podman', 'ps', '--filter', 'label=io.podman.compose.project=dc-case', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
['podman', 'network', 'exists', 'dc-case_default']
podman create --name=dc-case_hw_1 --label io.podman.compose.config-hash=64b000fe36278bbdb2b36618d97a587cbdb46e6036d71cbadc100e774c5bbb85 --label io.podman.compose.project=dc-case --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@dc-case.service --label com.docker.compose.project=dc-case --label com.docker.compose.project.working_dir=/home/iid/src/dc-case --label com.docker.compose.project.config_files=base-dc.yaml --label com.docker.compose.container-number=1 --label com.docker.compose.service=hw -v /home/iid/src/dc-case/resources:/resources:Z --net dc-case_default --network-alias hw busybox cat /resources/hello.txt
b66f8dab4bb0a662571c39428b00c5d258e58a72b72aaed6dc25e3fb4300bcca
exit code: 0
podman start -a dc-case_hw_1
[hw] | Hello World
exit code: 0

$ sudo /usr/local/bin/podman-compose -f extended/extended-dc.yaml up
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.4.1
** excluding: set()
['podman', 'ps', '--filter', 'label=io.podman.compose.project=extended', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
['podman', 'network', 'exists', 'extended_default']
['podman', 'network', 'create', '--label', 'io.podman.compose.project=extended', '--label', 'com.docker.compose.project=extended', 'extended_default']
['podman', 'network', 'exists', 'extended_default']
podman create --name=extended_hw-ext_1 --label io.podman.compose.config-hash=bb6a905e82ed0acbdbc6aea5189ff8b6b47ff3a713f58fd0d686a0a67f2bffff --label io.podman.compose.project=extended --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@extended.service --label com.docker.compose.project=extended --label com.docker.compose.project.working_dir=/home/iid/src/dc-case/extended --label com.docker.compose.project.config_files=extended/extended-dc.yaml --label com.docker.compose.container-number=1 --label com.docker.compose.service=hw-ext -v /home/iid/src/dc-case/extended/resources:/resources:Z --net extended_default --network-alias hw-ext busybox cat /resources/hello.txt
9bf48c104bec003ece65224a1e44a6ae68bce7f686c450092aa2958bcd17d0d9
exit code: 0
podman start -a extended_hw-ext_1
cat: can't open '/resources/hello.txt': No such file or directory
exit code: 1
```

**Environment:**
- OS: Linux (CentOS 9)
- podman version: 4.4.1
- podman compose version: 1.0.6

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.