Capstone: Wrap a Real App in Docker
Time to put it all together. We take a small web app, write its Dockerfile, run it with a port and an environment variable, and connect a database using Docker Compose — exactly the workflow you will repeat again and again in real work. Every decision here builds on what you already learned: cache,
It is like cooking a full meal after mastering each recipe separately: now you combine the ingredients — app, database, network — into one working dish.
- compose.yaml
- One file that describes all the app's services (web, db), the network between them, and the volumes. A single command, `docker compose up`, brings them all up together.
- service name
- Inside Compose, a service reaches another by its name (e.g. db), and the internal DNS resolves it to the right address. You do not use localhost between services.
- named volume
- Docker-managed storage attached to db, so data survives even when the container is removed and recreated. Without it, every restart loses the database.