You've written code that works on your laptop. You copy it to a cluster or send it to a collaborator, and it fails because a package is missing, a version is different, or a system library isn't there. This is one of the most common stalls in research computing, and containers are the usual fix.
What a container is
A container is a sealed bundle: your code, the programs it needs, and the exact versions of the libraries underneath. You build it once. Then it runs the same way on any machine that can run containers. Think of a lunchbox with the meal and the cutlery packed together, instead of hoping the kitchen you arrive at has a fork.
It isn't a full virtual machine. A container borrows the host computer's operating system, so it's small and starts quickly.
Docker and Apptainer
Docker is the tool most people meet first. It's common on laptops and in cloud services, and most public images are built with it.
Apptainer (earlier called Singularity) is what many research clusters offer. Shared systems can't give every user the administrator rights Docker normally needs, and Apptainer runs under your own account. It can also pull Docker images and run them, so you rarely have to choose one forever. National services like the ones in the OSPool and ACCESS article often ask for containers so that jobs behave the same on whichever machine picks them up.
When you need one
The software is hard to install. Some tools depend on a tangle of libraries. Someone already built a working image, so use it.
The code must run in several places. Laptop, campus cluster, cloud. A container removes the "it works on mine" problem. The where to run your research article covers how to pick among those.
Someone has to reproduce your work exactly. A container records the whole software stack, not just your package list. That goes a step beyond what the reproducible analysis article describes.
When you probably don't
If your project uses a handful of common Python or R packages, an environment file with pinned versions is usually enough. Containers add a learning step, and a beginner who spends a week on one before running a first job has often picked the wrong week. Get a tiny test run working first, as in the first-job guide.
A gentle way to start
Find an existing image for the tool you want, rather than building your own. Run it once on your laptop and once on a cluster that has Apptainer. Note the image name and version tag in your README and your Git history, so the choice is written down. Building your own image comes later, when you have a real reason, and a short recipe file (a Dockerfile or Apptainer definition file) kept next to your code is the right place for it.
Two cautions. Don't bake private or sensitive data into an image, since images get shared and copied. And pin a specific version tag instead of "latest," or the same recipe will quietly build something different next year.
For the wider picture, the research computing guide collects these articles in one place.
Common questions
Is a container the same as a virtual machine? Not quite. A virtual machine includes a whole operating system and is heavy. A container shares the host's operating system and carries only your software and its libraries, so it's smaller and starts in seconds.
Why do clusters use Apptainer instead of Docker? Docker usually needs administrator rights on the machine, which shared clusters can't hand out to every user. Apptainer (formerly called Singularity) runs as you, with your normal permissions, and it can run most Docker images.
Do I need a container for a small project? Often not. If your code runs from a short list of packages and a recorded environment file, that's enough. Containers pay off when the software is hard to install, when the same code must run on several systems, or when you want someone else to reproduce it exactly.
Where do I find a ready-made container? Many tools publish images on public registries such as Docker Hub or Quay.io, and some communities keep curated sets (bioinformatics is a good example). Check who maintains an image and when it was last updated before you rely on it.