Skip to content

Commit 406feef

Browse files
authored
Merge branch 'master' into master
2 parents 4259b1a + 4423eba commit 406feef

4 files changed

Lines changed: 130 additions & 136 deletions

File tree

build.md

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,49 @@
88

99
## Introduction
1010

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
1414
in a portable way.
1515

1616
## Definitions
1717

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
2222
can build image from source.
2323

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.
2525

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
2929
SHOULD warn user accordingly.
3030

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
3434
Dockerfile path is used.
3535

36-
3736
## Consistency with Image
3837

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
4342
request.
4443

4544
## Publishing built images
4645

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
4948
missing `Image` attribute which prevent image being pushed.
5049

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`
5352
attribute, whenever the actual raw yaml file doesn't explicitly declare one.
5453

55-
5654
## Illustrative sample
5755

5856
The following sample illustrates Compose specification concepts with a concrete sample application. The sample is non-normative.
@@ -73,38 +71,36 @@ services:
7371
build: ~/custom
7472
```
7573
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:
7775
7876
* `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.
7977
* `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.
8078
* 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.
8179

82-
8380
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.
8481

8582
## Build definition
8683

8784
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:
8986

9087
```yml
9188
services:
9289
webapp:
9390
build: ./dir
9491
```
9592

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.
9794
This path MUST be a directory and contain a `Dockerfile`.
9895

99-
10096
Alternatively `build` can be an object with fields defined as follow
10197

10298
### context (REQUIRED)
10399

104100
`context` defines either a path to a directory containing a Dockerfile, or a url to a git repository.
105101

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
108104
for being portable.
109105

110106
```yml
@@ -115,10 +111,9 @@ build:
115111
### dockerfile
116112

117113
`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
119115
for being portable.
120116

121-
122117
```yml
123118
build:
124119
context: .
@@ -130,6 +125,7 @@ build:
130125
`args` define build arguments, i.e. Dockerfile `ARG` values.
131126

132127
Using following Dockerfile:
128+
133129
```Dockerfile
134130
ARG GIT_COMMIT
135131
RUN echo "Based on commit: $GIT_COMMIT"
@@ -140,7 +136,7 @@ RUN echo "Based on commit: $GIT_COMMIT"
140136
```yml
141137
build:
142138
context: .
143-
args:
139+
args:
144140
GIT_COMMIT: cdc3b19
145141
```
146142

@@ -151,7 +147,7 @@ build:
151147
- GIT_COMMIT=cdc3b19
152148
```
153149

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,
155151
otherwise build arg won't be set when building the Docker image.
156152

157153
```yml
@@ -191,12 +187,12 @@ configuration, which means for Linux `/etc/hosts` will get extra lines:
191187

192188
### isolation
193189

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
195191
are platform-specific.
196192

197193
### labels
198194

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.
200196

201197
reverse-DNS notation SHOULD be used to prevent labels from conflicting with those used by other software.
202198

@@ -245,7 +241,6 @@ build:
245241
target: prod
246242
```
247243

248-
249244
## Implementations
250245

251246
* [docker-compose](https://docs.docker.com/compose)

deploy.md

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,26 @@ Compose specification is a platform-neutral way to define multi-container applic
1212
deployment of application model MAY require some additional metadata as the Compose application model is way too abstract
1313
to reflect actual infrastructure needs per service, or lifecycle constraints.
1414

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
1616
relevant data to allocate adequate resources on platform and configure them to match user's needs.
1717

18-
1918
## Definitions
2019

2120
Compose Specification is extended to support an OPTIONAL `deploy` subsection on services. This section define runtime requirements
2221
for a service.
2322

24-
2523
### endpoint_mode
2624

2725
`endpoint_mode` specifies a service discovery method for external clients connecting to a service. Default and available values
2826
are platform specific, anyway the Compose specification define two canonical values:
2927

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
3230
many nodes are participating in the service or their IP addresses or ports.
3331

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
3533
list of IP addresses (DNS round-robin), and the client connects directly to one of these.
3634

37-
3835
```yml
3936
services:
4037
frontend:
@@ -47,7 +44,6 @@ services:
4744
endpoint_mode: vip
4845
```
4946
50-
5147
### labels
5248
5349
`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:
6258
com.example.description: "This label will appear on the web service"
6359
```
6460

65-
6661
### mode
6762

6863
`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`.
6964

70-
7165
```yml
7266
services:
7367
frontend:
@@ -85,42 +79,39 @@ services:
8579
`constraints` defines a REQUIRED property the platform's node MUST fulfill to run service container. Can be set either
8680
by a list or a map with string values.
8781

88-
8982
```yml
9083
deploy:
91-
placement:
84+
placement:
9285
constraints:
93-
- disktype=ssd
86+
- disktype=ssd
9487
```
9588

9689
```yml
9790
deploy:
98-
placement:
91+
placement:
9992
constraints:
100-
disktype: ssd
93+
disktype: ssd
10194
```
10295

10396
#### preferences
10497

10598
`preferences` defines a property the platform's node SHOULD fulfill to run service container. Can be set either
10699
by a list or a map with string values.
107100

108-
109101
```yml
110102
deploy:
111-
placement:
103+
placement:
112104
preferences:
113-
- datacenter=us-east
105+
- datacenter=us-east
114106
```
115107

116108
```yml
117109
deploy:
118-
placement:
110+
placement:
119111
preferences:
120-
datacenter: us-east
112+
datacenter: us-east
121113
```
122114

123-
124115
### replicas
125116

126117
If the service is `replicated` (which is the default), `replicas` specifies the number of containers that SHOULD be
@@ -139,6 +130,7 @@ services:
139130

140131
`resources` configures physical resource constraints for container to run on platform. Those constraints can be configured
141132
as a:
133+
142134
- `limits`: The platform MUST prevent container to allocate more
143135
- `reservations`: The platform MUST guarantee container can allocate at least the configured amount
144136

@@ -221,7 +213,6 @@ deploy:
221213

222214
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.
223215

224-
225216
```yml
226217
deploy:
227218
resources:
@@ -252,7 +243,7 @@ deploy:
252243

253244
`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.
254245

255-
- `condition`: One of `none`, `on-failure` or `any` (default: `any`).
246+
- `condition`: One of `none`, `on-failure` or `any` (default: `any`).
256247
- `delay`: How long to wait between restart attempts, specified as a [duration](spec.md#specifying-durations) (default: 0).
257248
- `max_attempts`: How many times to attempt to restart a container before giving up (default: never give up). If the restart does not
258249
succeed within the configured `window`, this attempt doesn't count toward the configured `max_attempts` value.
@@ -262,11 +253,11 @@ deploy:
262253

263254
```yml
264255
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
270261
```
271262

272263
### rollback_config
@@ -278,7 +269,7 @@ deploy:
278269
- `failure_action`: What to do if a rollback fails. One of `continue` or `pause` (default `pause`)
279270
- `monitor`: Duration after each task update to monitor for failure `(ns|us|ms|s|m|h)` (default 0s).
280271
- `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),
282273
or `start-first` (new task is started first, and the running tasks briefly overlap) (default `stop-first`).
283274

284275
### update_config
@@ -290,14 +281,13 @@ deploy:
290281
- `failure_action`: What to do if an update fails. One of `continue`, `rollback`, or `pause` (default: `pause`).
291282
- `monitor`: Duration after each task update to monitor for failure `(ns|us|ms|s|m|h)` (default 0s).
292283
- `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),
294285
or `start-first` (new task is started first, and the running tasks briefly overlap) (default `stop-first`).
295286

296-
297287
```yml
298288
deploy:
299-
update_config:
300-
parallelism: 2
301-
delay: 10s
302-
order: stop-first
289+
update_config:
290+
parallelism: 2
291+
delay: 10s
292+
order: stop-first
303293
```

schema/compose-spec.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@
366366
"stdin_open": {"type": "boolean"},
367367
"stop_grace_period": {"type": "string", "format": "duration"},
368368
"stop_signal": {"type": "string"},
369+
"storage_opt": {"type": "object"},
369370
"tmpfs": {"$ref": "#/definitions/string_or_list"},
370371
"tty": {"type": "boolean"},
371372
"ulimits": {

0 commit comments

Comments
 (0)