# Container

> A sealed box that holds an app and all it needs. It runs the same anywhere.

**Field:** Infrastructure  
**Category:** Containers  
**Also known as:** Software Container, Linux Container, Containerized App

## Think of it like

It is like a lunch box. The whole meal is packed inside, so it travels well.

## Definition

A container is a sealed box for one app. It holds the app's code and every file the app needs to run. Because it brings its own files, it runs the same on a laptop and on a server. Many containers can share one machine, and each stays in its own space. They are lighter than a virtual machine, because they share the machine's core system, the kernel.

## Example

Lucy's web app works on her laptop but breaks on the server. She packs it into a container, and now it runs the same in both places.

## Example code

```console
$ docker run -d -p 8080:80 nginx
$ curl -s localhost:8080 | grep title
<title>Welcome to nginx!</title>
```

One line starts a web server in a container. Port 8080 on the laptop leads to port 80 inside it.

## Why it matters

It ends the old excuse that it works on my machine. The same box runs in testing and in the real world.

## Common mistake

Saving files inside the container and hoping they stay. When the box is removed, its files go with it.

## Three principles

- **Self-contained.** It carries every file the app needs.
- **Kept apart.** Each container sees only its own space.
- **Easy to replace.** Throw one away and start a fresh copy.

## Related terms

- [Container Image](https://learn.benibix.com/term/infrastructure/container-image)
- [Docker](https://learn.benibix.com/term/infrastructure/docker)
- [Container Runtime](https://learn.benibix.com/term/infrastructure/container-runtime)
- [Kubernetes Pod](https://learn.benibix.com/term/infrastructure/kubernetes-pod)
- [Virtual Machine (VM)](https://learn.benibix.com/term/infrastructure/virtual-machine)
- [Microservices](https://learn.benibix.com/term/development/microservices)
- [Environment (Software)](https://learn.benibix.com/term/development/environment)

## Told apart from

- [Container Image vs Container](https://learn.benibix.com/compare/container-image-vs-container): People use image and container as if they meant the same thing, and they do not. An image is the saved package, and it never changes. A container is one copy of it that is running right now. One image can start many containers. Delete a container, and the image is still there to start a new one.
- [Kubernetes Pod vs Container](https://learn.benibix.com/compare/kubernetes-pod-vs-container): People think a pod is just the Kubernetes word for a container, and it is not. A pod is a wrapper around one container or a few. The containers in one pod share an address and start and stop together. Kubernetes places and replaces pods, never loose containers. Most pods hold one container, which is why the two get mixed up.
- [Virtual Machine vs Container](https://learn.benibix.com/compare/virtual-machine-vs-container): People think a virtual machine and a container are the same thing, and they are not. A virtual machine is a whole computer in software, with its own operating system. A container is just an app and its parts. It shares the system of the machine it runs on. So a container starts in seconds and is much smaller. A VM keeps its users further apart.

![Two stacks side by side on the same hardware. On the left, virtual machines: a hypervisor carries two boxes, and each box holds a whole guest operating system with one app on top. On the right, containers: one operating system kernel and a container runtime carry three slim boxes, each holding only an app and its libraries.](https://learn.benibix.com/diagrams/inf-container-vm.svg)

---

Source: https://learn.benibix.com/term/infrastructure/container
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
