Compose uses the project name (which defaults to the basename of the project directory) internally to isolate projects from each other. The project name is used to create unique identifiers for all of the project’s containers and other resources. For example, if your project name is myapp
and it includes two services db
and web
, then Compose starts containers named myapp_db_1
and myapp_web_1
respectively.
You get the "Found orphan containers"
warning because docker-compose
detects some containers which belong to another project with the same name.
To prevent different projects from interfering with each other (and suppress the warning) you can set a custom project name by using any of the following options:
- The
-p
command line option. COMPOSE_PROJECT_NAME
environment variable. This environment variable can also be set via an environment file (.env
in the current working directory by default).- Top-level
name
element in the Compose file. Note: if you pass multiple files todocker-compose
via the-f
option, then the value from the last file will be used.