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
Copy file name to clipboardExpand all lines: build.md
+33-38Lines changed: 33 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,51 +8,49 @@
8
8
9
9
## Introduction
10
10
11
-
Compose specification is a platform-neutral way to define multi-container applications. A Compose implementation
12
-
focussing on development use-case to run application on local machine will obviously also support (re)building
13
-
application from sources. The Compose Build specification allows to define the build process within a Compose file
11
+
Compose specification is a platform-neutral way to define multi-container applications. A Compose implementation
12
+
focussing on development use-case to run application on local machine will obviously also support (re)building
13
+
application from sources. The Compose Build specification allows to define the build process within a Compose file
14
14
in a portable way.
15
15
16
16
## Definitions
17
17
18
-
Compose Specification is extended to support an OPTIONAL `build` subsection on services. This section define the
19
-
build requirements for service container image. Only a subset of Compose file services MAY define such a Build
20
-
subsection, others being created based on `Image` attribute. When a Build subsection is present for a service, it
21
-
is *valid* for a Compose file to miss an `Image` attribute for corresponding service, as Compose implementation
18
+
Compose Specification is extended to support an OPTIONAL `build` subsection on services. This section define the
19
+
build requirements for service container image. Only a subset of Compose file services MAY define such a Build
20
+
subsection, others being created based on `Image` attribute. When a Build subsection is present for a service, it
21
+
is *valid* for a Compose file to miss an `Image` attribute for corresponding service, as Compose implementation
22
22
can build image from source.
23
23
24
-
Build can be either specified as a single string defining a context path, or as a detailled build definition.
24
+
Build can be either specified as a single string defining a context path, or as a detailed build definition.
25
25
26
-
In the former case, the whole path is used as a Docker context to execute a docker build, looking for a canonical
27
-
`Dockerfile` at context root. Context path can be absolute or relative, and if so relative path MUST be resolved
28
-
from Compose file parent folder. As an absolute path prevent the Compose file to be portable, Compose implementation
26
+
In the former case, the whole path is used as a Docker context to execute a docker build, looking for a canonical
27
+
`Dockerfile` at context root. Context path can be absolute or relative, and if so relative path MUST be resolved
28
+
from Compose file parent folder. As an absolute path prevent the Compose file to be portable, Compose implementation
29
29
SHOULD warn user accordingly.
30
30
31
-
In the later case, build arguments can be specified, including an alternate `Dockerfile` location. This one can be
32
-
absolute or relative path. If Dockerfile path is relative, it MUST be resolved from context path. As an absolute
33
-
path prevent the Compose file to be portable, Compose implementation SHOULD warn user if an absolute alternate
31
+
In the later case, build arguments can be specified, including an alternate `Dockerfile` location. This one can be
32
+
absolute or relative path. If Dockerfile path is relative, it MUST be resolved from context path. As an absolute
33
+
path prevent the Compose file to be portable, Compose implementation SHOULD warn user if an absolute alternate
34
34
Dockerfile path is used.
35
35
36
-
37
36
## Consistency with Image
38
37
39
-
When service definition do include both `Image` attribute and a `Build` section, Compose implementation can't
40
-
guarantee a pulled image is strictly equivalent to building the same image from sources. Without any explicit
41
-
user directives, Compose implementation with Build support MUST first try to pull Image, then build from source
42
-
if image was not found on registry. Compose implementation MAY offer options to customize this behaviour by user
38
+
When service definition do include both `Image` attribute and a `Build` section, Compose implementation can't
39
+
guarantee a pulled image is strictly equivalent to building the same image from sources. Without any explicit
40
+
user directives, Compose implementation with Build support MUST first try to pull Image, then build from source
41
+
if image was not found on registry. Compose implementation MAY offer options to customize this behaviour by user
43
42
request.
44
43
45
44
## Publishing built images
46
45
47
-
Compose implementation with Build support SHOULD offer an option to push built images to a registry. Doing so, it
48
-
MUST NOT try to push service images without an `Image` attribute. Compose implementation SHOULD warn user about
46
+
Compose implementation with Build support SHOULD offer an option to push built images to a registry. Doing so, it
47
+
MUST NOT try to push service images without an `Image` attribute. Compose implementation SHOULD warn user about
49
48
missing `Image` attribute which prevent image being pushed.
50
49
51
-
Compose implementation MAY offer a mechanism to compute an `Image` attribute for service when not explicitly
52
-
declared in yaml file. In such a case, the resulting Compose configuration is considered to have a valid `Image`
50
+
Compose implementation MAY offer a mechanism to compute an `Image` attribute for service when not explicitly
51
+
declared in yaml file. In such a case, the resulting Compose configuration is considered to have a valid `Image`
53
52
attribute, whenever the actual raw yaml file doesn't explicitly declare one.
54
53
55
-
56
54
## Illustrative sample
57
55
58
56
The following sample illustrates Compose specification concepts with a concrete sample application. The sample is non-normative.
@@ -73,38 +71,36 @@ services:
73
71
build: ~/custom
74
72
```
75
73
76
-
When used to build service images from source, such a Compose file will create three docker images:
74
+
When used to build service images from source, such a Compose file will create three docker images:
77
75
78
76
* `awesome/webapp` docker image is build using `webapp` sub-directory within Compose file parent folder as docker build context. Lack of a `Dockerfile` within this folder will throw an error.
79
77
* `awesome/database` docker image is build using `backend` sub-directory within Compose file parent folder. `backend.Dockerfile` file is used to define build steps, this file is searched relative to context path, which means for this sample `..` will resolve to Compose file parent folder, so `backend.Dockerfile` is a sibling file.
80
78
* a docker image is build using `custom` directory within user's HOME as docker context. Compose implementation warn user about non-portable path used to build image.
81
79
82
-
83
80
On push, both `awesome/webapp` and `awesome/database` docker images are pushed to (default) registry. `custom` service image is skipped as no `Image` attribute is set and user is warned about this missing attribute.
84
81
85
82
## Build definition
86
83
87
84
The `build` element define configuration options that are applied by Compose implementations to build Docker image from source.
88
-
`build` can be specified either as a string containing a path to the build context or a detailled structure:
85
+
`build` can be specified either as a string containing a path to the build context or a detailed structure:
89
86
90
87
```yml
91
88
services:
92
89
webapp:
93
90
build: ./dir
94
91
```
95
92
96
-
Using this string syntax, only the build context can be configured as a relative path to the Compose file's parent folder.
93
+
Using this string syntax, only the build context can be configured as a relative path to the Compose file's parent folder.
97
94
This path MUST be a directory and contain a `Dockerfile`.
98
95
99
-
100
96
Alternatively `build` can be an object with fields defined as follow
101
97
102
98
### context (REQUIRED)
103
99
104
100
`context`defines either a path to a directory containing a Dockerfile, or a url to a git repository.
105
101
106
-
When the value supplied is a relative path, it MUST be interpreted as relative to the location of the Compose file.
107
-
Compose implementations MUST warn user about absolute path used to define build context as those prevent Compose file
102
+
When the value supplied is a relative path, it MUST be interpreted as relative to the location of the Compose file.
103
+
Compose implementations MUST warn user about absolute path used to define build context as those prevent Compose file
108
104
for being portable.
109
105
110
106
```yml
@@ -115,10 +111,9 @@ build:
115
111
### dockerfile
116
112
117
113
`dockerfile`allows to set an alternate Dockerfile. A relative path MUST be resolved from the build context.
118
-
Compose implementations MUST warn user about absolute path used to define Dockerfile as those prevent Compose file
114
+
Compose implementations MUST warn user about absolute path used to define Dockerfile as those prevent Compose file
119
115
for being portable.
120
116
121
-
122
117
```yml
123
118
build:
124
119
context: .
@@ -130,6 +125,7 @@ build:
130
125
`args`define build arguments, i.e. Dockerfile `ARG` values.
131
126
132
127
Using following Dockerfile:
128
+
133
129
```Dockerfile
134
130
ARG GIT_COMMIT
135
131
RUN echo "Based on commit: $GIT_COMMIT"
@@ -140,7 +136,7 @@ RUN echo "Based on commit: $GIT_COMMIT"
140
136
```yml
141
137
build:
142
138
context: .
143
-
args:
139
+
args:
144
140
GIT_COMMIT: cdc3b19
145
141
```
146
142
@@ -151,7 +147,7 @@ build:
151
147
- GIT_COMMIT=cdc3b19
152
148
```
153
149
154
-
Value can be omited when specifying a build argument, in which case its value at build time MUST be obtained by user interaction,
150
+
Value can be omitted when specifying a build argument, in which case its value at build time MUST be obtained by user interaction,
155
151
otherwise build arg won't be set when building the Docker image.
156
152
157
153
```yml
@@ -191,12 +187,12 @@ configuration, which means for Linux `/etc/hosts` will get extra lines:
191
187
192
188
### isolation
193
189
194
-
`isolation`specifies a build’s container isolation technology. Like [isolation](spec.md#isolation) supported values
190
+
`isolation`specifies a build’s container isolation technology. Like [isolation](spec.md#isolation) supported values
195
191
are platform-specific.
196
192
197
193
### labels
198
194
199
-
`labels`add metadata to the resulting image. `labrls` can be set either as an array or a map.
195
+
`labels`add metadata to the resulting image. `labels` can be set either as an array or a map.
200
196
201
197
reverse-DNS notation SHOULD be used to prevent labels from conflicting with those used by other software.
Copy file name to clipboardExpand all lines: deploy.md
+25-35Lines changed: 25 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,29 +12,26 @@ Compose specification is a platform-neutral way to define multi-container applic
12
12
deployment of application model MAY require some additional metadata as the Compose application model is way too abstract
13
13
to reflect actual infrastructure needs per service, or lifecycle constraints.
14
14
15
-
Compose Specification Deployment allows users to declare additional metadata on services so Compose implementations get
15
+
Compose Specification Deployment allows users to declare additional metadata on services so Compose implementations get
16
16
relevant data to allocate adequate resources on platform and configure them to match user's needs.
17
17
18
-
19
18
## Definitions
20
19
21
20
Compose Specification is extended to support an OPTIONAL `deploy` subsection on services. This section define runtime requirements
22
21
for a service.
23
22
24
-
25
23
### endpoint_mode
26
24
27
25
`endpoint_mode` specifies a service discovery method for external clients connecting to a service. Default and available values
28
26
are platform specific, anyway the Compose specification define two canonical values:
29
27
30
-
*`endpoint_mode: vip`: Assigns the service a virtual IP (VIP) that acts as the front end for clients to reach the service
31
-
on a network. Platform routes requests between the client and nodes running the service, without client knowledge of how
28
+
*`endpoint_mode: vip`: Assigns the service a virtual IP (VIP) that acts as the front end for clients to reach the service
29
+
on a network. Platform routes requests between the client and nodes running the service, without client knowledge of how
32
30
many nodes are participating in the service or their IP addresses or ports.
33
31
34
-
*`endpoint_mode: dnsrr`: Platform sets up DNS entries for the service such that a DNS query for the service name returns a
32
+
*`endpoint_mode: dnsrr`: Platform sets up DNS entries for the service such that a DNS query for the service name returns a
35
33
list of IP addresses (DNS round-robin), and the client connects directly to one of these.
36
34
37
-
38
35
```yml
39
36
services:
40
37
frontend:
@@ -47,7 +44,6 @@ services:
47
44
endpoint_mode: vip
48
45
```
49
46
50
-
51
47
### labels
52
48
53
49
`labels` specifies metadata for the service. These labels MUST *only* be set on the service and *not* on any containers for the service.
@@ -62,12 +58,10 @@ services:
62
58
com.example.description: "This label will appear on the web service"
63
59
```
64
60
65
-
66
61
### mode
67
62
68
63
`mode`define the replication model used to run the service on platform. Either `global` (exactly one container per physical node) or `replicated` (a specified number of containers). The default is `replicated`.
69
64
70
-
71
65
```yml
72
66
services:
73
67
frontend:
@@ -85,42 +79,39 @@ services:
85
79
`constraints`defines a REQUIRED property the platform's node MUST fulfill to run service container. Can be set either
86
80
by a list or a map with string values.
87
81
88
-
89
82
```yml
90
83
deploy:
91
-
placement:
84
+
placement:
92
85
constraints:
93
-
- disktype=ssd
86
+
- disktype=ssd
94
87
```
95
88
96
89
```yml
97
90
deploy:
98
-
placement:
91
+
placement:
99
92
constraints:
100
-
disktype: ssd
93
+
disktype: ssd
101
94
```
102
95
103
96
#### preferences
104
97
105
98
`preferences`defines a property the platform's node SHOULD fulfill to run service container. Can be set either
106
99
by a list or a map with string values.
107
100
108
-
109
101
```yml
110
102
deploy:
111
-
placement:
103
+
placement:
112
104
preferences:
113
-
- datacenter=us-east
105
+
- datacenter=us-east
114
106
```
115
107
116
108
```yml
117
109
deploy:
118
-
placement:
110
+
placement:
119
111
preferences:
120
-
datacenter: us-east
112
+
datacenter: us-east
121
113
```
122
114
123
-
124
115
### replicas
125
116
126
117
If the service is `replicated` (which is the default), `replicas` specifies the number of containers that SHOULD be
@@ -139,6 +130,7 @@ services:
139
130
140
131
`resources`configures physical resource constraints for container to run on platform. Those constraints can be configured
141
132
as a:
133
+
142
134
- `limits`: The platform MUST prevent container to allocate more
143
135
- `reservations`: The platform MUST guarantee container can allocate at least the configured amount
144
136
@@ -221,7 +213,6 @@ deploy:
221
213
222
214
If `device_ids` is set, Compose implementations MUST reserve devices with the specified IDs providing they satisfy the requested capabilities. The value is specified as a list of strings.
223
215
224
-
225
216
```yml
226
217
deploy:
227
218
resources:
@@ -252,7 +243,7 @@ deploy:
252
243
253
244
`restart_policy`configures if and how to restart containers when they exit. If `restart_policy` is not set, Compose implementations MUST consider `restart` field set by service configuration.
254
245
255
-
- `condition`: One of `none`, `on-failure` or `any` (default: `any`).
246
+
- `condition`: One of `none`, `on-failure` or `any` (default: `any`).
256
247
- `delay`: How long to wait between restart attempts, specified as a [duration](spec.md#specifying-durations) (default: 0).
257
248
- `max_attempts`: How many times to attempt to restart a container before giving up (default: never give up). If the restart does not
258
249
succeed within the configured `window`, this attempt doesn't count toward the configured `max_attempts` value.
@@ -262,11 +253,11 @@ deploy:
262
253
263
254
```yml
264
255
deploy:
265
-
restart_policy:
266
-
condition: on-failure
267
-
delay: 5s
268
-
max_attempts: 3
269
-
window: 120s
256
+
restart_policy:
257
+
condition: on-failure
258
+
delay: 5s
259
+
max_attempts: 3
260
+
window: 120s
270
261
```
271
262
272
263
### rollback_config
@@ -278,7 +269,7 @@ deploy:
278
269
- `failure_action`: What to do if a rollback fails. One of `continue` or `pause` (default `pause`)
279
270
- `monitor`: Duration after each task update to monitor for failure `(ns|us|ms|s|m|h)` (default 0s).
280
271
- `max_failure_ratio`: Failure rate to tolerate during a rollback (default 0).
281
-
- `order`: Order of operations during rollbacks. One of `stop-first` (old task is stopped before starting new one),
272
+
- `order`: Order of operations during rollbacks. One of `stop-first` (old task is stopped before starting new one),
282
273
or `start-first` (new task is started first, and the running tasks briefly overlap) (default `stop-first`).
283
274
284
275
### update_config
@@ -290,14 +281,13 @@ deploy:
290
281
- `failure_action`: What to do if an update fails. One of `continue`, `rollback`, or `pause` (default: `pause`).
291
282
- `monitor`: Duration after each task update to monitor for failure `(ns|us|ms|s|m|h)` (default 0s).
292
283
- `max_failure_ratio`: Failure rate to tolerate during an update.
293
-
- `order`: Order of operations during updates. One of `stop-first` (old task is stopped before starting new one),
284
+
- `order`: Order of operations during updates. One of `stop-first` (old task is stopped before starting new one),
294
285
or `start-first` (new task is started first, and the running tasks briefly overlap) (default `stop-first`).
0 commit comments