You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Summary
Removed repeated text about path behavior in the Compose Build
Specification documentation.
## Changes
- Consolidated duplicate sentences about absolute/relative path behavior
that appeared in both the "former case" and "latter case" paragraphs
- Improved clarity by explicitly referencing "When `build` is specified
as a string" and "When `build` is specified as a detailed structure"
instead of vague "former/latter" references
- Added a single consolidated paragraph explaining path behavior that
applies to both cases
Fixes#24163
---
🤖 Generated with [cagent](https://github.com/docker/cagent)
In the former case, the whole path is used as a Docker context to execute a Docker build, looking for a canonical
13
-
`Dockerfile` at the root of the directory. The path can be absolute or relative. If it is relative, it is resolved
14
-
from the directory containing your Compose file. If it is absolute, the path prevents the Compose file from being portable so Compose displays a warning.
12
+
When `build` is specified as a string, the whole path is used as a
13
+
Docker context to execute a Docker build, looking for a canonical
14
+
`Dockerfile` at the root of the directory.
15
15
16
-
In the latter case, build arguments can be specified, including an alternate `Dockerfile` location. The path can be absolute or relative. If it is relative, it is resolved
17
-
from the directory containing your Compose file. If it is absolute, the path prevents the Compose file from being portable so Compose displays a warning.
16
+
When `build` is specified as a detailed structure, build arguments can
17
+
be specified, including an alternate `Dockerfile` location.
18
18
19
-
## Using `build` and `image`
19
+
In both cases, the path can be absolute or relative. If it is relative,
20
+
it is resolved from the directory containing your Compose file. If it is
21
+
absolute, the path prevents the Compose file from being portable so
22
+
Compose displays a warning.
20
23
21
-
When Compose is confronted with both a `build`subsection for a service and an `image` attribute, it follows the rules defined by the [`pull_policy`](services.md#pull_policy) attribute.
24
+
## Using `build` and `image`
22
25
23
-
If `pull_policy` is missing from the service definition, Compose attempts to pull the image first and then builds from source if the image isn't found in the registry or platform cache.
26
+
When Compose is confronted with both a `build` subsection for a service and an `image` attribute, it follows the rules defined by the [`pull_policy`](services.md#pull_policy) attribute.
24
27
28
+
If `pull_policy` is missing from the service definition, Compose attempts to pull the image first and then builds from source if the image isn't found in the registry or platform cache.
25
29
26
30
## Publishing built images
27
31
@@ -49,9 +53,9 @@ services:
49
53
50
54
When used to build service images from source, the Compose file creates three Docker images:
51
55
52
-
*`example/webapp`: A Docker image is built using `webapp` sub-directory, within the Compose file's folder, as the Docker build context. Lack of a `Dockerfile` within this folder returns an error.
53
-
* `example/database`: A Docker image is built using `backend` sub-directory within the Compose file's folder. `backend.Dockerfile` file is used to define build steps, this file is searched relative to the context path, which means `..` resolves to the Compose file's folder, so `backend.Dockerfile` is a sibling file.
54
-
* A Docker image is built using the `custom` directory with the user's `$HOME` as the Docker context. Compose displays a warning about the non-portable path used to build image.
56
+
-`example/webapp`: A Docker image is built using `webapp` sub-directory, within the Compose file's folder, as the Docker build context. Lack of a `Dockerfile` within this folder returns an error.
57
+
-`example/database`: A Docker image is built using `backend` sub-directory within the Compose file's folder. `backend.Dockerfile` file is used to define build steps, this file is searched relative to the context path, which means `..` resolves to the Compose file's folder, so `backend.Dockerfile` is a sibling file.
58
+
-A Docker image is built using the `custom` directory with the user's `$HOME` as the Docker context. Compose displays a warning about the non-portable path used to build image.
55
59
56
60
On push, both `example/webapp` and `example/database` Docker images are pushed to the default registry. The `custom` service image is skipped as no `image` attribute is set and Compose displays a warning about this missing attribute.
57
61
@@ -61,6 +65,7 @@ The `build` subsection defines configuration options that are applied by Compose
61
65
`build` can be specified either as a string containing a path to the build context or as a detailed structure:
62
66
63
67
Using the string syntax, only the build context can be configured as either:
68
+
64
69
- A relative path to the Compose file's folder. This path must be a directory and must contain a `Dockerfile`
65
70
66
71
```yml
@@ -70,8 +75,8 @@ Using the string syntax, only the build context can be configured as either:
70
75
```
71
76
72
77
- A Git repository URL. Git URLs accept context configuration in their fragment section, separated by a colon (`:`).
73
-
The first part represents the reference that Git checks out, and can be either a branch, a tag, or a remote reference.
74
-
The second part represents a subdirectory inside the repository that is used as a build context.
78
+
The first part represents the reference that Git checks out, and can be either a branch, a tag, or a remote reference.
79
+
The second part represents a subdirectory inside the repository that is used as a build context.
75
80
76
81
```yml
77
82
services:
@@ -124,20 +129,20 @@ layers between service images.
124
129
125
130
```yaml
126
131
services:
127
-
base:
128
-
build:
129
-
context: .
130
-
dockerfile_inline: |
131
-
FROM alpine
132
-
RUN ...
133
-
my-service:
134
-
build:
135
-
context: .
136
-
dockerfile_inline: |
137
-
FROM base # image built for service base
138
-
RUN ...
139
-
additional_contexts:
140
-
base: service:base
132
+
base:
133
+
build:
134
+
context: .
135
+
dockerfile_inline: |
136
+
FROM alpine
137
+
RUN ...
138
+
my-service:
139
+
build:
140
+
context: .
141
+
dockerfile_inline: |
142
+
FROM base # image built for service base
143
+
RUN ...
144
+
additional_contexts:
145
+
base: service:base
141
146
```
142
147
143
148
### `args`
@@ -185,7 +190,6 @@ Compose Build implementations may support custom types, the Compose Specificatio
185
190
186
191
- `registry`to retrieve build cache from an OCI image set by key `ref`
187
192
188
-
189
193
```yml
190
194
build:
191
195
context: .
@@ -205,8 +209,8 @@ Unsupported caches are ignored and don't prevent you from building images.
205
209
build:
206
210
context: .
207
211
cache_to:
208
-
- user/app:cache
209
-
- type=local,dest=path/to/cache
212
+
- user/app:cache
213
+
- type=local,dest=path/to/cache
210
214
```
211
215
212
216
Cache target is defined using the same `type=TYPE[,KEY=VALUE]` syntax defined by [`cache_from`](#cache_from).
@@ -232,7 +236,7 @@ services:
232
236
build: https://github.com/mycompany/webapp.git
233
237
```
234
238
235
-
If not set explicitly, `context` defaults to project directory (`.`).
239
+
If not set explicitly, `context` defaults to project directory (`.`).
236
240
237
241
### `dockerfile`
238
242
@@ -272,11 +276,11 @@ build:
272
276
273
277
`entitlements`defines extra privileged entitlements to be allowed during the build.
274
278
275
-
```yaml
276
-
entitlements:
277
-
- network.host
278
-
- security.insecure
279
-
```
279
+
```yaml
280
+
entitlements:
281
+
- network.host
282
+
- security.insecure
283
+
```
280
284
281
285
### `extra_hosts`
282
286
@@ -288,6 +292,7 @@ extra_hosts:
288
292
- "otherhost=50.31.209.229"
289
293
- "myhostv6=::1"
290
294
```
295
+
291
296
IPv6 addresses can be enclosed in square brackets, for example:
292
297
293
298
```yml
@@ -349,7 +354,7 @@ Set the network containers connect to for the `RUN` instructions during build.
349
354
build:
350
355
context: .
351
356
network: host
352
-
```
357
+
```
353
358
354
359
```yaml
355
360
build:
@@ -390,6 +395,7 @@ When the `platforms` attribute is defined, Compose includes the service's
390
395
platform, otherwise users won't be able to run images they built.
391
396
392
397
Composes reports an error in the following cases:
398
+
393
399
- When the list contains multiple platforms but the implementation is incapable of storing multi-platform images.
394
400
- When the list contains an unsupported platform.
395
401
@@ -400,6 +406,7 @@ Composes reports an error in the following cases:
400
406
- "linux/amd64"
401
407
- "unsupported/unsupported"
402
408
```
409
+
403
410
- When the list is non-empty and does not contain the service's platform.
`provenance`configures the builder to add a [provenance attestation](https://slsa.dev/provenance/v0.2#schema) to the published image.
438
+
`provenance`configures the builder to add a [provenance attestation](https://slsa.dev/provenance/v0.2#schema) to the published image.
432
439
433
440
The value can be either a boolean to enable/disable provenance attestation, or a key=value string to set provenance configuration. You can
434
441
use this to select the level of detail to be included in the provenance attestation by setting the `mode` parameter.
@@ -454,7 +461,7 @@ available in the local image store.
454
461
455
462
{{< summary-bar feature_name="Compose sbom" >}}
456
463
457
-
`sbom`configures the builder to add a [provenance attestation](https://slsa.dev/provenance/v0.2#schema) to the published image.
464
+
`sbom`configures the builder to add a [provenance attestation](https://slsa.dev/provenance/v0.2#schema) to the published image.
458
465
The value can be either a boolean to enable/disable sbom attestation, or a key=value string to set SBOM generator configuration. This let you
459
466
select an alternative SBOM generator image (see https://github.com/moby/buildkit/blob/master/docs/attestations/sbom-protocol.md)
460
467
@@ -551,23 +558,27 @@ Such grant must be explicit within service specification as [secrets](services.m
551
558
`ssh`defines SSH authentications that the image builder should use during image build (e.g., cloning private repository).
552
559
553
560
`ssh` property syntax can be either:
554
-
* `default`: Let the builder connect to the SSH-agent.
555
-
* `ID=path`: A key/value definition of an ID and the associated path. It can be either a [PEM](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail) file, or path to ssh-agent socket.
561
+
562
+
- `default`: Let the builder connect to the SSH-agent.
563
+
- `ID=path`: A key/value definition of an ID and the associated path. It can be either a [PEM](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail) file, or path to ssh-agent socket.
556
564
557
565
```yaml
558
566
build:
559
567
context: .
560
568
ssh:
561
-
- default # mount the default SSH agent
569
+
- default # mount the default SSH agent
562
570
```
571
+
563
572
or
573
+
564
574
```yaml
565
575
build:
566
576
context: .
567
-
ssh: ["default"] # mount the default SSH agent
577
+
ssh: ["default"] # mount the default SSH agent
568
578
```
569
579
570
580
Using a custom id `myproject` with path to a local SSH key:
581
+
571
582
```yaml
572
583
build:
573
584
context: .
@@ -591,7 +602,7 @@ as an integer value representing the number of bytes or as a string expressing a
0 commit comments