Dockerize a 3-tier App
Containerize a web + API + DB stack and wire it with Compose.
0 of 6 steps
What you will end up with
Three services in containers
A working Compose file
Persistent database storage
Build steps
0/6Start FROM a small base image, COPY your frontend files in, then CMD to serve them. It reads like a packing list: which box, what goes inside, which door opens.
Same recipe, different ingredients: a base image for your language runtime, COPY the code in, RUN install the dependencies, then CMD to start the server.
In docker-compose.yml, add a service block for something like postgres, with an image, env vars for the user and password, and a port. It is one more room added to the house you are building.
Compose creates a shared network automatically, so services reach each other by name, like db, instead of an IP address. Each room gets a name instead of a street address.
Add a volumes block mapping a named volume to the database’s data directory. Skip this and deleting the container erases the data too, like writing on a whiteboard instead of paper.
Run docker compose up --build. That single command builds every image and starts every service in the right order, automatically.
Before you start