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:
Bhavin Gandhi 2022-06-05 23:14:50 +05:30 committed by Muayyad Alsadi
parent 847f01a6c6
commit 0b853f29f4
5 changed files with 22 additions and 2 deletions

View File

@ -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]

View 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

View 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

View File

@ -0,0 +1 @@
The file from docker-compose.yaml

View File

@ -0,0 +1 @@
The file from docker-compose.override.yaml