-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Description
By default, Compose bases the project name on basename of the directory compose
commands are run from. The project name can be overridden either by
passing a -p / --project-name
option for each command or setting the
COMPOSE_PROJECT_NAME
environment variable.
Using the --project-name
option for each command is error-prone and for-
getting to pass the option when doing (for example) docker-compose up
, will result in
another instance of the project being created under a different name or even
containers of a different project being replaced.
Using the COMPOSE_PROJECT_NAME
environment variable is not useful when dealing
with multiple projects and can cause similar problems.
Proposal: make project-name persistent
To solve these problems, compose will save the name of a project to a file in the
build-context when the project is first started / built.
If a project-file is found, compose automatically uses the project-name from that
file and throw an exception if the user is trying to override the project-name
using the --project-name
option.
File location
To allow further expansion of options, compose creates a hidden .docker-compose
directory
in the "root" directory of the build-context. Inside that directory, a
project-name
file is created, containing just the name of the project;
tree -a
.
├── .docker-compose
│ └── project-name
└── docker-compose.yml
Request for comment
There are a couple of things left to be discussed;
- Should the configuration-file be created automatically or should this
be an explicit action by the user (e.g.docker-compose init --project-name=foobar
) - Should a command be added to remove the configuration file(s)? (e.g.
docker-compose destroy
) - Compose allows specifying an alternative compose-file (
--file
) should the
project-name also be applied to those? Should each compose-file get its own
configuration?
And, in a wider scope;
- Is the project-name actually important? If not, compose could create a random
project-name and store that inside the configuration. This would greatly reduce
the risk of conflicting names with other projects running on the same server.
edit: renamed Fig to Compose