Pcornel
Browse topics
Options
Recent
Favorites
Containers · Technical reference

Container Isolation and Security Defaults

Direct answer

Container isolation and security defaults: containers run with dropped capabilities, seccomp and AppArmor/SELinux profiles, but often as root inside. Hardening adds non-root users, read-only root filesystems, no privilege escalation and minimal capabilities.

When to use this

Use it when hardening containers or reviewing a pod's security settings.

First 30 seconds

1. docker inspect <c> --format '{{.Config.User}} {{.HostConfig.Privileged}} {{.HostConfig.CapAdd}}'.

2. Kubernetes: kubectl get pod <p> -o yaml | grep -A10 securityContext.

3. Namespace PSA labels: kubectl get ns <ns> --show-labels.

4. Fix in image/spec.

5. Re-deploy and test.

Operational verification

image user → runtime defaults (caps, seccomp, LSM) → pod securityContext → admission policy

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Docker / containerd / Podman / Kubernetes / OCI-compatible platforms
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.

PlatformDocker / containerd / Podman / Kubernetes / OCI-compatible platforms
Scope / prerequisiteUse it when hardening containers or reviewing a pod's security settings.
What next?2 suggested next steps
Evidence0
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.

2 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 How to verify Verify boundary

Run as a non-root user (USER in the image or --user). Add only the single capability a feature needs with --cap-add. Use --read-only and tmpfs for writable paths, and confirm the settings with docker inspect.

Step 2 Common failures Narrow the fault

Granting --privileged to fix one permission error opens the host. Mounting the Docker socket into a container gives it root on the host. Disabling the LSM profile hides the real cause of a denial.

Key points

Avoid --privileged, hostPath and host namespaces. Run as non-root (USER, runAsNonRoot), drop all capabilities and add back only needed ones, set allowPrivilegeEscalation: false and readOnlyRootFilesystem. Enforce with Pod Security Admission (restricted).

Key checks
  • docker ps -a — containers and exit codes
  • docker logs <c> — container output
  • docker inspect <c> — config, mounts, network, state
ReferenceWhat it is1 section · depth on demand

How it works

A container starts as root inside its user namespace unless a user is set. Capabilities split root powers into small units; the runtime keeps a minimal set. Seccomp filters syscalls; AppArmor or SELinux limit file and network access. Rootless runtimes add a user namespace so container root maps to an unprivileged host user.

ReferenceImportant terms & boundaries3 sections · depth on demand

Default protections and how to tighten

MechanismDefaultTighten with
Namespaces (pid, net, mnt, uts, ipc)On--userns / user namespaces
cgroups (CPU, memory, pids)No limits--memory, --cpus, --pids-limit
CapabilitiesReduced set--cap-drop ALL --cap-add <needed>
SeccompDefault profileCustom profile
AppArmor/SELinuxDefault profileCustom profile
Root filesystemWritable--read-only + tmpfs
UserrootUSER 10001 in Dockerfile

Never use --privileged, the host network/PID namespace or the Docker socket mount for untrusted workloads.

In depth

Container isolation is layered. Each layer covers a different attack path, and removing one is not compensated by the others.

LayerDefault in Docker/containerdWhat it stops
Namespacespid, net, mnt, uts, ipcSeeing and signalling host processes, host network
CapabilitiesReduced set (no SYS_ADMIN, NET_ADMIN, SYS_MODULE …)Mounting filesystems, loading modules, changing host network
SeccompDefault profile blocks around 40+ syscallsRare, dangerous syscalls such as kexec_load, open_by_handle_at
AppArmor / SELinuxdocker-default profile or container_t typeWriting to host paths outside the container
No new privilegesOff by default; --security-opt no-new-privilegessetuid binaries gaining privileges
User namespaceOff by defaultRoot in the container being root on the host

What --privileged actually does

It grants all capabilities, disables seccomp and the LSM profile, and exposes host devices. Treat it as running the process on the host.

Worked check — what does this container really have?

docker inspect -f '{{.HostConfig.Privileged}} {{.HostConfig.CapAdd}} {{.HostConfig.SecurityOpt}}' web
docker exec web grep -E 'CapEff|NoNewPrivs|Seccomp' /proc/1/status
# CapEff: 00000000a80425fb   Seccomp: 2 (filter active)   NoNewPrivs: 1

capsh --decode=<CapEff> turns the mask into capability names. Seccomp: 0 means no filter is active.

Practical hardening order

Non-root user → drop all capabilities and add back only what is needed → read-only root filesystem with tmpfs for scratch paths → no-new-privileges → never mount the Docker or containerd socket into a workload.

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

Common mistakes

  • Running as root and with --privileged.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
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 isolation and security defaultscontainer capabilities seccomprootless containers
Confirmation

Confirm action

Continue?