Reproducible Research › Module 4: Environments
Containers, briefly
Lesson 3 of 3 · 2 min
Pinning packages fixes most problems. But the operating system and system libraries can still differ. A container packages everything: the operating system layer, the libraries, the language and your code.
The idea
Think of a shipping container: whatever is inside, it fits on any ship, train or truck. A software container runs the same on any computer that has a container tool installed.
Docker
Docker, released in 2013, made containers popular. You write a short text file, a Dockerfile, that says: start from this base system, install these packages, copy in this code. Anyone can build the same container from it.
ExampleA minimal Dockerfile for a Python project: start from python:3.11-slim, copy requirements.txt, run pip install -r requirements.txt, copy the code, and set the command to python run_all.py.
On shared computers
University clusters often don't allow Docker for security reasons. They use Apptainer (formerly Singularity), which can run Docker images safely.
Do you need one?
- No, for most coursework and small analyses: pinned versions are enough.
- Yes, when your project depends on system libraries, specific GPU drivers, or must run unchanged for years.
Some ML conferences award artifact badges to papers whose code and environment others could rerun; containers make that much easier.
RememberContainers package the whole environment. Use them when pinned packages aren't enough to make results repeatable.