Enterprise Virtual, Cloud, and Wireless Network Protection · Topic 2 of 5

OS Virtualization, Containers, Docker and Kubernetes Security

Learn OS virtualization and the security best practices for containers, Docker and Kubernetes that CND 312-38 candidates must recognize and apply.

  • 5 min
In a nutshell
  • Containers share the host kernel, VMs do not.
  • Namespaces isolate, cgroups limit resources.
  • Run containers as non root, not privileged, with limited capabilities.

What it is

OS virtualization, also called containerization, lets many isolated user space instances share one operating system kernel. Each instance is a container. Containers start fast and use little memory, but they do not have a separate kernel the way a VM does.

Docker is the best known container platform, and Kubernetes is the orchestrator that schedules and manages containers across many hosts. The exam asks which practices make them safer.

Imagepackaged appRegistrystored and signedContainerrunning on host kernelKubernetesschedules many containers

How it works

OS virtualization security

Isolation comes from the Linux kernel: namespaces limit what a container can see (processes, network, mounts), and control groups (cgroups) limit how much CPU and memory it can use. Because the kernel is shared, a kernel flaw or an over privileged container can affect the host and every other container.

FeatureVMContainer
KernelOwn guest kernelShares the host kernel
IsolationStrong, hypervisor enforcedWeaker, kernel enforced
Start timeMinutesSeconds
SizeGigabytesMegabytes

Container security best practices

  • Use small, trusted base images, and scan every image for known vulnerabilities before use.
  • Run as a non root user, and avoid privileged mode.
  • Drop unneeded Linux capabilities and apply seccomp, AppArmor or SELinux profiles.
  • Use a read only filesystem where possible.
  • Set CPU and memory limits to stop one container from starving others.
  • Never bake secrets (passwords, keys) into an image. Use a secrets store.
  • Keep the host kernel and runtime patched, and use a minimal host operating system.
  • Sign images and pull only from trusted registries.
  • Monitor runtime behavior and log container activity.

Docker security best practices

Docker has a client, a daemon (dockerd), images and registries. The daemon runs with high privilege, so access to it is equal to root on the host.

AreaPractice
Daemon accessDo not expose the Docker socket (/var/run/docker.sock) to containers. Do not give users access to the docker group without need
Remote APIProtect with TLS (the secured port is 2376, and 2375 is unencrypted) and never expose it to the internet
ImagesUse Docker Content Trust to verify signed images, and scan images
ContainersRun with --read-only where possible, avoid privileged mode, and set resource limits
NetworkingUse user defined networks instead of the default bridge, and publish only needed ports
HardeningFollow the CIS Docker Benchmark and check with the Docker Bench for Security tool
AuditingAudit the daemon, enable logging and keep Docker up to date

User namespaces map root inside a container to an unprivileged user on the host, which limits damage from an escape.

Kubernetes security best practices

Kubernetes has a control plane and worker nodes.

ComponentRole
API serverFront door for all commands. Everything goes through it
etcdKey-value store holding all cluster state and secrets
Scheduler and controller managerPlace pods and keep the desired state
kubeletAgent on each node that runs pods
kube-proxyNetwork rules for services on each node

Practices:

  • RBAC: give each user and service account only the permissions it needs. Disable anonymous access to the API server.
  • Network policies: by default every pod can reach every pod. Add policies that allow only required traffic.
  • Pod Security Standards: three levels, Privileged, Baseline and Restricted. Enforce at least Baseline, and Restricted for sensitive workloads.
  • Secrets: stored base64 encoded, which is not encryption. Enable encryption at rest for etcd and restrict access to it.
  • Protect etcd and the kubelet: require authentication and TLS, and never expose them to the internet.
  • Audit logging: record API server requests.
  • Admission controllers: reject non compliant pods before they run.
  • Keep Kubernetes patched and scan images in the pipeline.
  • Use the CIS Kubernetes Benchmark, which tools such as kube-bench check.
Buildscan and sign imageDeployadmission policy checksRunRBAC, network policy, limitsMonitoraudit and runtime logs

A worked example

A developer mounts the Docker socket into a container so a build tool can start other containers. Anyone who compromises that container can start a privileged container and take over the host.

The defender removes the socket mount, runs the build with a rootless or isolated builder, and blocks privileged pods in Kubernetes with a Restricted Pod Security Standard.

How the exam asks about this

  • "Which Linux feature limits the resources a container can use?" → Control groups (cgroups).
  • "In Kubernetes, which component stores cluster state and secrets?" → etcd.
  • "Which benchmark gives hardening guidance for Docker?" → The CIS Docker Benchmark.

What to remember for the exam

  • Containers share the host kernel, VMs do not.
  • Namespaces isolate, cgroups limit resources.
  • Run containers as non root, not privileged, with limited capabilities.
  • Access to the Docker socket is equal to root on the host.
  • Kubernetes defenses are RBAC, network policies, Pod Security Standards, secret protection and audit logs.
Watch out

Kubernetes secrets are only base64 encoded by default. Encoding is not encryption.

Common mistakes

Believing containers are as isolated as VMs. A shared kernel means a kernel vulnerability can reach the host.

Leaving the default network wide open. Without network policies, a single compromised pod can reach all others.

Trusting images because they come from a public registry. Scan and verify images before running them.

Check yourself

  • Why is mounting the Docker socket into a container dangerous?

    It gives that container control of the Docker daemon, which is equivalent to root on the host.

  • What do Kubernetes network policies do?

    They restrict which pods may talk to each other, because the default allows all traffic.

  • Which Pod Security Standard level is the most restrictive?

    Restricted.

Topic 2 of 5 in Enterprise Virtual, Cloud, and Wireless Network Protection

Test yourself on Enterprise Virtual, Cloud, and Wireless Network Protection

The full EC-Council 312-38 question bank has 800 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by EC-Council. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.