containers / containers/podman-compose
volumes are not properly merged when using long format
- Dominant language
- Python
- Stars
- 6.2k
- Forks
- 622
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When using the long syntax for the volumes, they are not properly merged which results in the duplicated volumes.
```
#docker-compose.yaml
version: "3"
services:
web:
image: busybox
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8080"]
ports:
- 8080:8080
volumes:
- type: bind
source: ./index.txt
target: /var/www/html/index.html
read_only: true
bind:
selinux: z
- type: bind
source: ./index.txt
target: /var/www/html/index2.html
- type: bind
source: ./index.txt
target: /var/www/html/index3.html
read_only: true
```
```
# docker-compose.override.yaml
version: "3"
services:
web:
volumes:
- type: bind
source: ./override.txt
target: /var/www/html/index.html
read_only: true
bind:
selinux: "z"
- type: bind
source: ./override.txt
target: /var/www/html/index2.html
bind:
selinux: "z"
- type: bind
source: ./override.txt
target: /var/www/html/index3.html
```
result is
```
$ podman-compose -f docker-compose.yaml -f docker-compose.override.yaml config
services:
web:
command:
- /bin/busybox
- httpd
- -f
- -h
- /var/www/html
- -p
- '8080'
image: busybox
ports:
- 8080:8080
volumes:
- bind:
selinux: z
read_only: true
source: ./index.txt
target: /var/www/html/index.html
type: bind
- source: ./index.txt
target: /var/www/html/index2.html
type: bind
- read_only: true
source: ./index.txt
target: /var/www/html/index3.html
type: bind
- bind:
selinux: z
read_only: true
source: ./override.txt
target: /var/www/html/index.html
type: bind
- bind:
selinux: z
source: ./override.txt
target: /var/www/html/index2.html
type: bind
- source: ./override.txt
target: /var/www/html/index3.html
type: bind
version: '3'
```
When using the short syntax (`./index.txt:/var/www/html/index.html:ro,z`) it works as expected.
Short syntax case is covered by tests (https://github.com/containers/podman-compose/tree/main/tests/integration/merge/volumes_merge) but long is not.
**To Reproduce**
1. create files docker-compose.yaml and docker-compose.override.yaml as specified in description
2. run `podman-compose -f docker-compose.yaml -f docker-compose.override.yaml config`
**Expected behavior**
the resulting compose file should have only 3 volumes, with correctly overwritten source path.
**Actual behavior**
the resulting compose file has 6 volumes, it incorrectly merges volumes from docker-compose and docker-compose.override together
**Output**
```
$ podman-compose version
podman-compose version 1.3.0
podman version 5.4.2
```
**Environment:**
- OS: Mac
- podman version:
Contributor guide
Assessment
This issue has not been assessed yet.