A multi-container application runs its components in multiple coordinated containers. Frontend and backend layers can remain separate while Docker connects them through standard network protocols. section 7.0
Docker Compose describes and manages these applications. It runs multiple containers together on a single Docker Engine, making it useful for development and nonproduction environments. section 7.0 section 10.1
When running multiple copies, account for Compose’s project-based resource management:
- Compose identifies an application through a project name, defaulting to the directory containing the Compose file. section 10.1
- Project names prefix created resources, while containers also receive numeric suffixes. section 10.1
- Use different project names when separate copies would otherwise conflict over containers, ports, or files. section 10.1
Run a second application instance
Start one copy with `docker compose -f ./todo-list/docker-compose.yml up -d`, then start an isolated copy with `docker compose -f ./todo-list/docker-compose.yml -p todo-test up -d`. Inspect containers with `docker container ls` and check its port using `docker container port todo-test-todo-web-1 8080`. section 10.1
cd ./ch10/exercises # run the random number app from chapter 8: docker compose -f ./numbers/docker-compose.yml up -d # run the to-do list app from chapter 6: docker compose -f ./todo-list/docker-compose.yml up -d # and try another copy of the to-do list: docker compose -f ./todo-list/docker-compose.yml up -d
Follow the runnable Compose commands for the random-number and to-do-list applications, including an attempted duplicate launch. section 10.1
