A visual breakdown of how docker compose defines, networks, and runs multiple services as one application.
Your declarative definition of the app.
services:
mongodb:
image: mongo
mongo-express:
image: mongo-express
depends_on: [mongodb]
Key idea
Compose turns a set of containers into a single “application unit”.
You apply the desired state with one command.
What Compose does
All services join this network by default.
Service names become DNS names (e.g., mongodb).
Containers are namespaced by the project name.
Use volumes to keep DB data across restarts.
All services share one Compose network. Both mongo-express and my-app connect directly to mongodb.
Web UI container.
Application container.
Database container with optional persistence.
From your laptop, you typically hit localhost:8081 (mongo-express) and localhost:3000 (my-app).
Create network + containers and start them.
Aggregated logs from all services.
Keep containers; stop the processes.
Remove containers + network (and optionally volumes).