Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce top-level name #206

Merged
merged 4 commits into from Jan 22, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion schema/compose-spec.json
Expand Up @@ -8,7 +8,12 @@
"properties": {
"version": {
"type": "string",
"description": "Version of the Compose specification used. Tools not implementing required version MUST reject the configuration file."
"description": "declared for backward compatibility, ignored."
},

"name": {
"type": "string",
"description": "define the Compose project name, until user defines one explicitly."
},

"services": {
Expand Down
20 changes: 20 additions & 0 deletions spec.md
Expand Up @@ -49,6 +49,8 @@ A **Project** is an individual deployment of an application specification on a p
resources together and isolate them from other applications or other installation of the same Compose specified application with distinct parameters. A Compose implementation creating resources on a platform MUST prefix resource names by project and
set the label `com.docker.compose.project`.

Project name can be set explicitly by top-level `name` attribute. Compose implementation MUST offer a way for user to set a custom project name and override this name, so that the same `compose.yaml` file can be deployed twice on the same infrastructure, without changes, by just passing a distinct name.

### Illustrative example

The following example illustrates Compose specification concepts with a concrete example application. The example is non-normative.
Expand Down Expand Up @@ -223,6 +225,24 @@ Compose implementations SHOULD validate whether they can fully parse the Compose
because the Compose file was written with fields defined by a newer version of the specification, Compose implementations
SHOULD warn the user. Compose implementations MAY offer options to ignore unknown fields (as defined by ["loose"](#Requirements-and-optional-attributes) mode).

## Name top-level element

Top-level `name` property is defined by the specification as project name to be used if user doesn't set one explicitly.
Compose implementations MUST offer a way for user to override this name, and SHOULD define a mechanism to compute a
default project name, to be used if the top-level `name` element is not set.

Whenever project name is defined by top-level `name` or by some custom mechanism, it MUST be exposed for
[interpolation](#Interpolation) and environment variable resolution as `COMPOSE_PROJECT_NAME`

```yml
services:
foo:
image: busybox
environment:
- COMPOSE_PROJECT_NAME
command: echo "I'm running ${COMPOSE_PROJECT_NAME}"
```

## Services top-level element

A Service is an abstract definition of a computing resource within an application which can be scaled/replaced
Expand Down