Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

Containers Fundamentals

Direct answer

Container fundamentals: an image is a read-only layered filesystem plus metadata; a container is a running instance with its own writable layer, namespaces (pid, net, mnt, uts, ipc, user) and cgroup limits.

When to use this

Use it to understand how containers differ from VMs and why they share the host kernel.

First 30 seconds

1. docker inspect <c> --format '{{.State.Pid}}' → host PID.

2. Namespaces: lsns -p <pid>.

3. Limits: docker stats --no-stream.

4. Rootless? docker info | grep -i rootless.

5. Image layers: docker history <image>.

Operational verification

image layers + writable layer → namespaces isolate → cgroups limit → process on the shared kernel

Evidence · next step

For Containers → Containers Fundamentals, continue with the first unproven Topic check: Pin exact host, runtime/hypervisor, object identity, source revision/image/definition and failing workload. If that boundary is healthy, advance to the adjacent check: Read back effective runtime state including process, namespace/resource or virtual-hardware boundaries. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Scope / prerequisiteUse it to understand how containers differ from VMs and why they share the host kernel.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Operational evidence path Verify boundary

host kernel → namespaces → cgroups → root filesystem → capabilities/security policy → container process → workload

Healthy evidence: processes have the expected namespace membership, cgroup controls, filesystem view and capabilities

Step 2 Verification and output interpretation Verify boundary

Verification chain. host kernel → namespaces → cgroups → root filesystem → capabilities/security policy → container process → workload

Step 3 Commands Verify boundary
docker info
podman info
ps -ef | grep containerd
Step 4 Failure modes and next checks Narrow the fault

Suspicious evidence: a process appears containerized but shares unintended namespaces/resources or depends on host state unexpectedly

Step 5 Common mistakes Narrow the fault
  • Assuming containers are VMs (shared kernel).
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points

Containers share the host kernel — kernel features and vulnerabilities affect them. Rootless containers (Podman, rootless Docker) reduce risk. Limits (--memory, --cpus) protect the host.

Key checks
  • lsns -p <pid> — namespaces of a process
  • docker ps -a / podman ps -a — containers and state
  • docker logs <c> — container output
  • docker inspect <c> — configuration, mounts, network
  • docker info — engine, storage driver, cgroup version
ReferenceImportant terms & boundaries5 sections · depth on demand

What this shows and what it does not

The boundary is effective kernel isolation and resource control for the exact process set, not the presence of a container name or image.

In depth

Images, layers and the writable container layer

Container images are built from layers. Understanding them explains build speed, image size, and why container data disappears. Docker's documentation on image layers explains:

  • Every Dockerfile instruction that changes files produces one layer, which never changes after it's created.
  • Layers are stored by a digest of their contents, so identical layers are stored once and shared between images.
  • A running container adds a thin writable layer on top. Changes, including changes to files that came from the image, land in that layer.
  • Removing the container deletes its writable layer, and the image stays unchanged.
  • The build cache reuses unchanged steps. A step reruns when it or its inputs change, and every later step reruns with it.

Consequences in practice

BehaviourWhy
Data written inside a container is lost on removalIt's in the writable layer; use volumes
Deleting a file in a later layer doesn't shrink the imageThe earlier layer still contains it
Changing a line early in a Dockerfile rebuilds everything after itThe cache is invalidated from that step onwards
Many images on one host share base layersStored once by digest

Ordering a Dockerfile for the cache

OrderContent
1Base image
2System packages (changes rarely)
3Dependency manifests (package.json, requirements.txt)
4Install dependencies
5Application source (changes often)

Inspecting layers

host$ docker history --format '{{.Size}}\t{{.CreatedBy}}' report-api:1.4 | head -5
48.2MB  RUN /bin/sh -c pip install -r requirements.txt
1.1kB   COPY requirements.txt . # buildkit
212kB   COPY . . # buildkit
host$ docker image inspect report-api:1.4 -f '{{len .RootFS.Layers}} layers'
9 layers
host$ docker system df
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          14        6         3.9GB     2.2GB (56%)
Containers      7         6         412MB     8MB (1%)
Local Volumes   5         4         6.1GB     0B (0%)
host$ docker container diff web1 | head -3
C /var/cache/nginx
A /var/cache/nginx/client_temp

Reading the history

In this image, the source code COPY comes before pip install. Every source change therefore reruns the 48 MB dependency installation. Copying requirements.txt and installing it before COPY . . keeps that layer cached. docker container diff lists what a running container changed in its writable layer (A for added, C for changed).

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

How it works at runtime

Containers Fundamentals is part of Containers → Containers Fundamentals. Container fundamentals explains Linux containers as processes isolated primarily by namespaces and governed by cgroups, with layered filesystem and runtime metadata rather than hardware virtualization.

Topic-specific state model. Container fundamentals explains Linux containers as processes isolated primarily by namespaces and governed by cgroups, with layered filesystem and runtime metadata rather than hardware virtualization.

Quick reference

Containers are processes isolated with kernel features: namespaces (pid, net, mnt, uts, ipc, user, cgroup) give them their own view of the system, cgroups limit resources, capabilities/seccomp/LSMs restrict what they can do, and an image provides the root filesystem.

Runtime layerExamples
Engine/CLIDocker, Podman, nerdctl
High-level runtimecontainerd, CRI-O
Low-level runtime (OCI)runc, crun, gVisor, Kata
lsns                           # namespaces on the host
systemd-cgls | head
podman run --rm -it alpine sh -c 'cat /proc/1/cgroup; id'

Containers share the host kernel: kernel vulnerabilities and privileged containers break isolation.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Limits and how it fails

Primary failure point. The boundary is effective kernel isolation and resource control for the exact process set, not the presence of a container name or image.

Snapshot/image existence is not a verified backup.

ReferenceConfiguration & state1 section · depth on demand

Configuration, persistence and lifecycle

Distribution/platform context. Containers Fundamentals owns the Linux execution concepts; platform-specific lifecycle belongs to Docker or another runtime.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

Authoritative/upstream documentation reviewed for bounded claims in Containers → Containers Fundamentals. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://docs.docker.com/engine/ · confidence 94%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
container fundamentalslinux namespaces cgroups containerscontainer isolation
Embedded reference data

Quick lookup tables

Containers Fundamentals operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for Containers Fundamentals.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective stateContainer fundamentals explains Linux containers as processes isolated primarily by namespaces and governed by cgroups, with layered filesystem and runtime metadata rather than hardware virtualization.Establish exactly what this Topic owns before crossing into another subsystem.
Fast verificationPin host + object identity + source image/definition → verify host/runtime capability → read back effective process/namespace/cgroup or virtual-hardware state → verify storage/network attachments → verify guest/container readiness → repeat original workload + regression check.Use the shortest evidence path first; a fast check is a boundary test, not blanket proof.
Verification chainhost kernel → namespaces → cgroups → root filesystem → capabilities/security policy → container process → workloadTrace requested/configured state through effective state to the observed workload result.
Failure boundaryThe boundary is effective kernel isolation and resource control for the exact process set, not the presence of a container name or image.Stop broad troubleshooting at the first boundary that is not supported by evidence.
Positive evidenceCorrelated Linux container/virtualization evidence can establish this proof path: host kernel → namespaces → cgroups → root filesystem → capabilities/security policy → container process → workloadUse this observation only for the specific claim it actually supports.
Evidence limitIt does not independently prove unobserved clients, names, identities, routes, sessions, backends or time periods. The boundary is effective kernel isolation and resource control for the exact process set, not the presence of a container name or image.Do not promote a local success signal into end-to-end or adjacent-dependency proof.
Next troubleshooting checkContinue from the first unproven runtime boundary, capture adjacent host/object/resource/attachment evidence, make only the demonstrated persistent change, then repeat the original workload plus a regression check.Continue to the next unresolved boundary while preserving the original test condition.

Containers Fundamentals · operational reference

Compact Linux state, persistence, verification and boundary reference for fast lookup.

Reference boundaryContainers Fundamentals
Topic pathContainers → Containers Fundamentals
Runtime stateContainer fundamentals explains Linux containers as processes isolated primarily by namespaces and governed by cgroups, with layered filesystem and runtime metadata rather than hardware virtualization.
Fast checks- Pin exact host, runtime/hypervisor, object identity, source revision/image/definition and failing workload. - Read back effective runtime state including process, namespace/resource or virtual-hardware boundaries. - Trace storage and network attachments plus readiness from the real client or dependent workload path. - Apply the smallest persistent change, then repeat the original workload and an adjacent regression check.
Verification chainhost kernel → namespaces → cgroups → root filesystem → capabilities/security policy → container process → workload Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary.
Failure boundaryThe boundary is effective kernel isolation and resource control for the exact process set, not the presence of a container name or image. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload.
Persistence ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?