Skip to content

Commit 6bedc19

Browse files
gloursndeloof
authored andcommitted
update -p project name flag documentation
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
1 parent a11515e commit 6bedc19

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

docs/reference/compose.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,19 @@ $ docker compose -f ~/sandbox/rails/compose.yaml pull db
115115

116116
### Use `-p` to specify a project name
117117

118-
Each configuration has a project name. If you supply a `-p` flag, you can specify a project name. If you don’t
119-
specify the flag, Compose uses the current directory name.
120-
Project name can also be set by `COMPOSE_PROJECT_NAME` environment variable.
121-
122-
Many Compose subcommands can be run without a Compose file by passing
123-
the project name.
118+
Each configuration has a project name. Compose sets the project name using
119+
the following mechanisms, in order of precedence:
120+
- The `-p` command line flag
121+
- The `COMPOSE_PROJECT_NAME` environment variable
122+
- The top level `name:` variable from the config file (or the last `name:`
123+
from a series of config files specified using `-f`)
124+
- The `basename` of the project directory containing the config file (or
125+
containing the first config file specified using `-f`)
126+
- The `basename` of the current directory if no config file is specified
127+
Project names must contain only lowercase letters, decimal digits, dashes,
128+
and underscores, and must begin with a lowercase letter or decimal digit. If
129+
the `basename` of the project directory or current directory violates this
130+
constraint, you must use one of the other mechanisms.
124131

125132
```console
126133
$ docker compose -p my_project ps -a

docs/reference/docker_compose.yaml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,19 @@ long: |-
6363
6464
### Use `-p` to specify a project name
6565
66-
Each configuration has a project name. If you supply a `-p` flag, you can specify a project name. If you don’t
67-
specify the flag, Compose uses the current directory name.
68-
Project name can also be set by `COMPOSE_PROJECT_NAME` environment variable.
69-
70-
Many Compose subcommands can be run without a Compose file by passing
71-
the project name.
66+
Each configuration has a project name. Compose sets the project name using
67+
the following mechanisms, in order of precedence:
68+
- The `-p` command line flag
69+
- The `COMPOSE_PROJECT_NAME` environment variable
70+
- The top level `name:` variable from the config file (or the last `name:`
71+
from a series of config files specified using `-f`)
72+
- The `basename` of the project directory containing the config file (or
73+
containing the first config file specified using `-f`)
74+
- The `basename` of the current directory if no config file is specified
75+
Project names must contain only lowercase letters, decimal digits, dashes,
76+
and underscores, and must begin with a lowercase letter or decimal digit. If
77+
the `basename` of the project directory or current directory violates this
78+
constraint, you must use one of the other mechanisms.
7279
7380
```console
7481
$ docker compose -p my_project ps -a

0 commit comments

Comments
 (0)