Infrastructure and deployment
What is a Container?
Definition
A container is a process running on a shared host kernel with its own isolated filesystem, network and process view, packaged with everything it needs to run.
Also known as: OCI container, Linux container
Container in more detail
A container is not a small computer. It is an ordinary process that the kernel has been told to lie to: namespaces give it a private view of the filesystem, process table, network interfaces, users and hostnames, while cgroups cap how much CPU, memory and I/O it may consume. Run ps on the host and you see the process plainly; run it inside the container and it looks like PID 1 on a machine of its own.
Because there is no guest operating system, the overhead is close to nothing: containers start in milliseconds and a single host can run hundreds. The image is a stack of read-only layers containing the application and its dependencies, and every container adds a thin writable layer on top. Two containers from the same image share those layers on disk, which is why pulling a second image from the same base is nearly free.
The trade against a virtual machine is isolation strength. Containers share the host kernel, so a kernel vulnerability is a shared exposure and a container cannot run a different operating system — Linux containers on Windows or macOS are really running inside a hidden Linux VM. For hostile multi-tenant workloads people reach for VMs or sandboxed runtimes such as Firecracker or gVisor. Containers are also meant to be disposable: state belongs in a mounted volume or an external database, never in the writable layer.
Container example
The kernel features underneath
namespaces mnt, pid, net, uts, ipc, user -> what it can see
cgroups cpu, memory, io, pids -> what it can use
$ docker run --memory=512m --cpus=1.5 myapp:1.4
$ ps aux | grep myapp # on the HOST: just a process
Image layers are shared and cached
FROM node:22-alpine <- shared by every image built on it
COPY package*.json . <- changes rarely, cached
RUN npm ci <- rebuilt only when the layer above changes
COPY . . <- changes every commit
State does not live in the container
docker run -v pgdata:/var/lib/postgresql/data postgres:17Container — common questions
- What is the difference between a container and a virtual machine?
- A VM emulates hardware and runs its own full operating system on a hypervisor. A container shares the host's kernel and isolates only the process view. VMs isolate more strongly; containers start faster and use far fewer resources.
- What is the difference between an image and a container?
- An image is the immutable packaged filesystem and metadata; a container is a running instance of one, with a writable layer on top. The relationship is roughly that of a program on disk to a process in memory.
- Are containers secure by default?
- They are isolated, not sandboxed. Sharing the host kernel means a kernel exploit crosses the boundary, and running as root inside a container is a common mistake. Drop capabilities, run as a non-root user, use read-only filesystems and keep base images patched.
Keep reading
Every definition in the set is indexed A-Z in the developer glossary, and the cheat sheets cover the syntax once you know what you are looking for.
Browse the A-Z glossary