Docker interview question · Most asked

How do you secure Docker containers and images?

Summary

Use minimal, regularly rebuilt base images from trusted sources; scan images for vulnerabilities in CI and registries; sign images and verify signatures; run as non-root; drop capabilities (--cap-drop ALL); use a read-only root filesystem; set resource limits; never mount the Docker socket into containers; and keep secrets out of images.

Longer Answer

Additional measures: keep Docker Engine and the host kernel patched; use rootless Docker or user namespaces to reduce the impact of escapes; apply the default seccomp and AppArmor/SELinux profiles (never --privileged unless unavoidable); generate SBOMs; and restrict who can access the Docker daemon, because access to it (or its socket) is effectively root on the host.

Key Points

  • Minimal trusted images; scan and sign.
  • Non-root, drop capabilities, read-only FS.
  • Never mount docker.sock; no --privileged.
  • Daemon access = root.

More most-asked Docker questions

← All Docker questions