CSE Roadmap

Common tier · about 8 hours · 7 parts

Part 2 of 7 · 2 min read

The problem and the words

Why "works on my machine" keeps happening, and the five words that fix it.

You build a small service. It runs on your laptop. You send it to a teammate and it fails: they have a different Python version, a missing library, or a different operating system. You deploy it to a server and it fails again. Each machine is slightly different, and the differences are invisible until something breaks.

There are two separate ideas that solve this, and this module teaches both:

  1. Package the environment with the code, so that the service runs the same everywhere. This is what a container does.
  2. Check every change automatically on a clean machine, so that problems are found in minutes instead of by a teammate or a customer. This is what CI does.

Here are the words.

Image

A read-only package holding your code, its libraries and the operating-system files it needs. Think of it as a frozen, ready-to-run copy of the environment.

Container

A running instance of an image, isolated from the rest of the machine. You can start many containers from one image. Containers share the host computer's operating-system core (the kernel), so they start in seconds and are lighter than virtual machines, which each run a whole guest operating system.

Dockerfile

A text file with the build steps for an image, one instruction per line. Each instruction adds a layer: a saved step that Docker can reuse later if nothing changed.

Docker Compose

A file (compose.yaml) that describes one or more containers, with their ports and settings, so one command starts them all.

Continuous integration (CI)

Running automated checks on every push or pull request, on a clean machine, so problems are found within minutes. Continuous delivery or deployment (CD) goes one step further and ships a passing build automatically.

Docker is the most common program for building and running containers, and this module uses it. To follow along you need Docker Desktop (Windows and macOS) or Docker Engine (Linux).

Check yourself

  • What is the difference between an image and a container?
  • Why does a container start faster than a virtual machine?
  • What does CI do that "running the tests on my laptop" does not?