Container (software)
Also called Docker container, container image.
A package that holds an application and everything it needs to run, isolated from other software on the same machine.
Last updated
What it is.
A container image bundles the app code, runtime, libraries and settings. Running that image gives a container: an isolated process that shares the host's operating system kernel but has its own files and network. Containers start in seconds and are much lighter than virtual machines.
Images follow open standards, so the same image runs on a laptop, in CI and on any cloud. To run many containers across many machines, teams use an orchestrator such as Kubernetes or a managed container service.
Why it matters
Containers end it works on my machine. What was tested is exactly what ships. They also make it easier to move between hosting providers, which helps avoid lock-in, and to scale parts of a system on their own.
In a product build
We build one image per service in the pipeline, keep images small, run as a non-root user and scan them for known vulnerabilities. Config and secrets come from the environment, never baked into the image.
Common mistakes.
- 01
Putting secrets inside the image, where anyone with the image can read them.
- 02
Huge images with build tools left in, which are slow to ship and have more holes.
- 03
Storing data inside the container, which is lost when it restarts.
Related terms.
- Kubernetes (K8s)An open source platform that runs and manages containers across a group of machines: starting them, restarting them, scaling them and routing traffic to them.
- ServerlessA cloud model where the provider runs your code on demand and manages the servers, and you pay for what you use rather than for idle machines.
- CI/CD (continuous integration and delivery)An automated pipeline that builds and tests every code change (CI) and then releases it to users in a repeatable way (CD).
- Infrastructure as code (IaC)Defining servers, networks, databases and other cloud resources in code files that are versioned and applied automatically, instead of setting them up by hand.
- MicroservicesA way of building an application as many small services, each owning one job and its own data, deployed independently.