A project name identifies which resources belong to one Docker Compose application. Compose uses the directory name by default, then prefixes resource names with it. section 10.1
Use the project name to control deployment identity and resource naming:
- A Compose file in app1 can create app1-disk for a volume and app1-web-1 for a web container. section 10.1
- Scaled services add a numeric suffix, such as app1-web-2 for a second web container. section 10.1
- Repeating docker compose up from the same folder reuses the existing application instead of creating another copy. section 10.1
- Specify a different project name with -p to run separate copies of the same Compose application on one Docker Engine. section 10.1
Run a second to-do application
docker compose -f ./todo-list/docker-compose.yml -p todo-test up -d docker container ls docker container port todo-test-todo-web-1 8080 The explicit name makes this deployment distinct, and its predictable container name begins with todo-test. section 10.1
docker compose -f ./todo-list/docker-compose.yml -p todo-test up -d docker container ls docker container port todo-test-todo-web-1 8080
Inspect the created container and find its published port after assigning a project name. section 10.1
When override files define separate environments, give each deployment its own project name. The resulting containers and networks remain isolated, but management commands must repeat the same files and name. section 10.2
