forked from extern/podman-compose
Ignore access mode when merging volumes short syntax
The target path inside the container is treated as a key. Ref: https://github.com/compose-spec/compose-spec/blob/master/spec.md#merging-service-definitions Signed-off-by: Bhavin Gandhi <bhavin7392@gmail.com>
This commit is contained in:
parent
847f01a6c6
commit
0b853f29f4
@ -1315,11 +1315,11 @@ def rec_merge_one(target, source):
|
||||
if is_list(value2):
|
||||
if key == "volumes":
|
||||
# clean duplicate mount targets
|
||||
pts = {v.split(":", 1)[1] for v in value2 if ":" in v}
|
||||
pts = {v.split(":", 2)[1] for v in value2 if ":" in v}
|
||||
del_ls = [
|
||||
ix
|
||||
for (ix, v) in enumerate(value)
|
||||
if ":" in v and v.split(":", 1)[1] in pts
|
||||
if ":" in v and v.split(":", 2)[1] in pts
|
||||
]
|
||||
for ix in reversed(del_ls):
|
||||
del value[ix]
|
||||
|
7
tests/volumes_merge/docker-compose.override.yaml
Normal file
7
tests/volumes_merge/docker-compose.override.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
version: "3"
|
||||
services:
|
||||
web:
|
||||
volumes:
|
||||
- ./override.txt:/var/www/html/index.html:ro,z
|
||||
- ./override.txt:/var/www/html/index2.html:z
|
||||
- ./override.txt:/var/www/html/index3.html
|
11
tests/volumes_merge/docker-compose.yaml
Normal file
11
tests/volumes_merge/docker-compose.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
version: "3"
|
||||
services:
|
||||
web:
|
||||
image: busybox
|
||||
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8080"]
|
||||
ports:
|
||||
- 8080:8080
|
||||
volumes:
|
||||
- ./index.txt:/var/www/html/index.html:ro,z
|
||||
- ./index.txt:/var/www/html/index2.html
|
||||
- ./index.txt:/var/www/html/index3.html:ro
|
1
tests/volumes_merge/index.txt
Normal file
1
tests/volumes_merge/index.txt
Normal file
@ -0,0 +1 @@
|
||||
The file from docker-compose.yaml
|
1
tests/volumes_merge/override.txt
Normal file
1
tests/volumes_merge/override.txt
Normal file
@ -0,0 +1 @@
|
||||
The file from docker-compose.override.yaml
|
Loading…
Reference in New Issue
Block a user