core Estimated learning time: 5 h

10.5 Docker and reproducible environments

Your code runs identically on your laptop and the server.

Before:05. Classical Machine Learning

Docker freezes an environment — OS, Python, dependencies, CUDA — into an image that runs identically anywhere, ending works-on-my-machine as a sentence. Multi-stage builds and layer-cache awareness keep images lean and rebuilds fast. It sits here because serving and CI both stand on it. The GPU catch is specific: CUDA and driver version mismatches inside containers produce failures that look like anything except what they are.

Work through these

  • Dockerfile for a Python ML service

    A container definition for a Python service, which is how the environment travels with the code. This is the practical answer to it working on one machine only.

  • Layer caching, image size and multi-stage builds

    How layers are cached, why images grow large, and the build pattern that keeps the final image small. Build times and image sizes both improve substantially with these.

  • GPU containers and CUDA compatibility

    Containers using accelerators need matching driver and toolkit versions, and mismatches produce confusing failures. Knowing the compatibility question exists saves a long afternoon.

  • docker compose for local stacks

    Describing several services together so a whole stack starts with one command. It is what makes local development resemble production.

    Docker — Get Started · Tutorial

Sign in to keep your progress.

Free resources

Links last checked 29 Aug 2026.

Stuck here?

Ask a mentor. A real person answers, and they can see exactly which topic you're on. Usually within a couple of working days.

Checking your session…

Topics shown in module order.