Dockerise a full-stack app
Put an app, its database and a reverse proxy into containers so anyone can run it with one command.
Beginnerâą 5â8 hoursđĒ 7 stepsDockerDocker ComposeAny web app
What you'll learn
- âImages, containers and layers
- âMulti-stage builds
- âCompose networks, volumes and environment variables
What you'll build
- âdocker compose up starts everything
- âSmall production image
- âDatabase data survives restarts
- âHealth checks
Step-by-step guide
- 1
Pick an app
Use one of your projects (for example a Node or Spring Boot API with a database).
- 2
Write a Dockerfile
Multi-stage: build in a full image (node:20 / maven), copy only the output into a slim runtime image; run as a non-root user.
- 3
.dockerignore
Exclude node_modules, .git, .env and build output to keep images small and secrets out.
- 4
Compose file
Services: app, db (postgres:16 with a named volume), optional nginx; depends_on with a healthcheck condition.
- 5
Configuration
Pass settings through environment variables and an .env file that is not committed.
- 6
Health checks
HEALTHCHECK in the Dockerfile or compose calling /health.
- 7
Measure
Compare image sizes before and after multi-stage builds (docker images) and note it in the README.
đ Make it stand out
- +Push images to a registry
- +Run on a cloud VM
- +Hot reload in development with bind mounts