All topics / Dockerize an App

Dockerize an App

Take a small web app and containerize it - a real Dockerfile, image caching, and a compose file with a database - built and run on your machine.

  1. Why Containers, and a First Dockerfile Build a tiny Flask app, write a minimal Dockerfile for it, and run it inside a container on your machine.
  2. A Real Dockerfile Rework the Dockerfile so the layer cache speeds up rebuilds, the image shrinks, and the app runs as a non-root user.
  3. docker compose: App Plus Database Write a compose.yaml that runs the Flask app and a Postgres database together, with a volume and depends_on, brought up and down in one command.
  4. Ship It Move config out of the compose file into env vars and secrets, add a healthcheck, then tag the image and push it to a registry.