liveBook · Manning

Multi-container application

As explained in Learn Docker in a Month of Lunches, Second Edition

A multi-container application is an application whose components run in multiple coordinated containers.

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

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains component separation, networking, Compose management, and project-based naming, but does not detail application implementation.
Examples
Uses frontend-backend components, random-number and to-do-list applications, duplicate launches, and project-name commands.
What you can do after
Operate multiple application copies with Docker Compose by assigning project names and inspecting their containers and ports.
How it connects
Connects containers with Docker, Docker Compose, distributed applications, networking, and multiple environments.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.