@@ -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
0 commit comments