Skip to content

Commit 9da035f

Browse files
committed
formatting
1 parent 9beb7bf commit 9da035f

File tree

1 file changed

+119
-119
lines changed
  • content/manuals/compose/how-tos/multiple-compose-files

1 file changed

+119
-119
lines changed

content/manuals/compose/how-tos/multiple-compose-files/merge.md

Lines changed: 119 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -88,139 +88,139 @@ service, the local value replaces or extends the original value.
8888

8989
- For single-value options like `image`, `command` or `mem_limit`, the new value replaces the old value.
9090

91-
original service:
91+
original service:
9292

93-
```yaml
94-
services:
95-
myservice:
96-
# ...
97-
command: python app.py
98-
```
93+
```yaml
94+
services:
95+
myservice:
96+
# ...
97+
command: python app.py
98+
```
9999

100-
local service:
100+
local service:
101101

102-
```yaml
103-
services:
104-
myservice:
105-
# ...
106-
command: python otherapp.py
107-
```
102+
```yaml
103+
services:
104+
myservice:
105+
# ...
106+
command: python otherapp.py
107+
```
108108

109-
result:
109+
result:
110110

111-
```yaml
112-
services:
113-
myservice:
114-
# ...
115-
command: python otherapp.py
116-
```
111+
```yaml
112+
services:
113+
myservice:
114+
# ...
115+
command: python otherapp.py
116+
```
117117

118118
- For the multi-value options `ports`, `expose`, `external_links`, `dns`, `dns_search`, and `tmpfs`, Compose concatenates both sets of values:
119119

120-
original service:
121-
122-
```yaml
123-
services:
124-
myservice:
125-
# ...
126-
expose:
127-
- "3000"
128-
```
129-
130-
local service:
131-
132-
```yaml
133-
services:
134-
myservice:
135-
# ...
136-
expose:
137-
- "4000"
138-
- "5000"
139-
```
140-
141-
result:
142-
143-
```yaml
144-
services:
145-
myservice:
146-
# ...
147-
expose:
148-
- "3000"
149-
- "4000"
150-
- "5000"
151-
```
120+
original service:
121+
122+
```yaml
123+
services:
124+
myservice:
125+
# ...
126+
expose:
127+
- "3000"
128+
```
129+
130+
local service:
131+
132+
```yaml
133+
services:
134+
myservice:
135+
# ...
136+
expose:
137+
- "4000"
138+
- "5000"
139+
```
140+
141+
result:
142+
143+
```yaml
144+
services:
145+
myservice:
146+
# ...
147+
expose:
148+
- "3000"
149+
- "4000"
150+
- "5000"
151+
```
152152

153153
- In the case of `environment`, `labels`, `volumes`, and `devices`, Compose "merges" entries together with locally defined values taking precedence. For `environment` and `labels`, the environment variable or label name determines which value is used:
154154

155-
original service:
156-
157-
```yaml
158-
services:
159-
myservice:
160-
# ...
161-
environment:
162-
- FOO=original
163-
- BAR=original
164-
```
165-
166-
local service:
167-
168-
```yaml
169-
services:
170-
myservice:
171-
# ...
172-
environment:
173-
- BAR=local
174-
- BAZ=local
175-
```
176-
177-
result:
178-
179-
```yaml
180-
services:
181-
myservice:
182-
# ...
183-
environment:
184-
- FOO=original
185-
- BAR=local
186-
- BAZ=local
187-
```
155+
original service:
156+
157+
```yaml
158+
services:
159+
myservice:
160+
# ...
161+
environment:
162+
- FOO=original
163+
- BAR=original
164+
```
165+
166+
local service:
167+
168+
```yaml
169+
services:
170+
myservice:
171+
# ...
172+
environment:
173+
- BAR=local
174+
- BAZ=local
175+
```
176+
177+
result:
178+
179+
```yaml
180+
services:
181+
myservice:
182+
# ...
183+
environment:
184+
- FOO=original
185+
- BAR=local
186+
- BAZ=local
187+
```
188188

189189
- Entries for `volumes` and `devices` are merged using the mount path in the container:
190190

191-
original service:
192-
193-
```yaml
194-
services:
195-
myservice:
196-
# ...
197-
volumes:
198-
- ./original:/foo
199-
- ./original:/bar
200-
```
201-
202-
local service:
203-
204-
```yaml
205-
services:
206-
myservice:
207-
# ...
208-
volumes:
209-
- ./local:/bar
210-
- ./local:/baz
211-
```
212-
213-
result:
214-
215-
```yaml
216-
services:
217-
myservice:
218-
# ...
219-
volumes:
220-
- ./original:/foo
221-
- ./local:/bar
222-
- ./local:/baz
223-
```
191+
original service:
192+
193+
```yaml
194+
services:
195+
myservice:
196+
# ...
197+
volumes:
198+
- ./original:/foo
199+
- ./original:/bar
200+
```
201+
202+
local service:
203+
204+
```yaml
205+
services:
206+
myservice:
207+
# ...
208+
volumes:
209+
- ./local:/bar
210+
- ./local:/baz
211+
```
212+
213+
result:
214+
215+
```yaml
216+
services:
217+
myservice:
218+
# ...
219+
volumes:
220+
- ./original:/foo
221+
- ./local:/bar
222+
- ./local:/baz
223+
```
224224

225225
For more merging rules, see [Merge and override](/reference/compose-file/merge.md) in the Compose Specification.
226226

0 commit comments

Comments
 (0)