Docker for Software Development

Why Smarter. Docker is usually taught with a single container that prints “hello world”, or a two-service example that bears little resemblance to production. Smarter gives students a realistic multi-container application on day one, the same one that runs in production:

  • One Dockerfile with twelve stages. The Dockerfile builds on a slim Python 3.14 base, adds system packages, kubectl, the MariaDB connector and the AWS CLI, creates a non-root smarter_user with its own virtual environment, and, outside local development, makes the application’s files read-only, so that a compromised process cannot rewrite its own code.

  • Six services in one Compose file. docker-compose.yml runs a Django web server under uvicorn, two Celery workers on separate queues, a Celery scheduler, MariaDB and Redis, with health checks and start-up dependencies.

  • One image, four roles. The web server, both workers and the scheduler run the same image with different commands, configured entirely through the environment, as ADR 004 on the twelve-factor app requires.

  • A real developer workflow. The docker-* targets in the Makefile wrap every step, from make docker-init, which creates the database and loads the platform’s built-in resources, to a rebuild that takes seconds because it skips collecting static assets.

  • From laptop to production. GitHub Actions builds the image for linux/amd64 and linux/arm64 and pushes it to Amazon ECR, the Quick Start runs a prebuilt image with its own Compose file, and the Helm chart runs the same image on Kubernetes.

The files also have real flaws for students to find and fix: unpinned mariadb:latest and redis:latest images, an EXPOSE that names the wrong port, and two Compose files that use different databases. Students learn as much from questioning a working setup as from building one.

What the course covers. Why containers, and what virtual machines and containers each isolate; namespaces, control groups and union file systems; inspecting images and containers; the Dockerfile, the build cache and layer ordering; multi-stage builds; users, permissions and file ownership; Compose services, networks, volumes, health checks and dependencies; configuration through the environment; one image in many roles, and logs as event streams; smaller, faster and safer images, with scanning and signing; building and publishing images in CI; and what changes on the way to production and Kubernetes.

Look at.

Each course plan lists every file that it uses under Smarter in the Source Code.

Read. Docker, ADR 002 on Docker, ADR 004 on the twelve-factor app, Build, Quick Start Guide.

Exercises.

  • Annotate the Dockerfile: what each stage does, why the application runs as a non-root user, and how the image size could be reduced.

  • Use docker exec, docker logs and docker stats to follow a chat request from the web server to a Celery worker, which writes its charge and history.

  • Explain why the same image runs as the web server, the workers and the scheduler.

  • Compare the development Compose file with the Quick Start’s, and decide which differences are deliberate and which are drift.

Course plans. Three complete, ready-to-teach plans, each with a schedule, graded assignments and rubrics, two capstone projects, recommended texts, further study and technical prerequisites. See Course Formats and Grading for what the formats have in common.

See the Smarter Instructor Guide to install Smarter and set up a class.