Back to course

Securing Containers (Docker basics)

Cyber Security Mastery: From Zero to Hero

Containers and Cybersecurity

Containers (like Docker) allow developers to package an application with all its dependencies into a standard unit for development and deployment. They are lightweight alternatives to VMs.

Container Security Risks

  1. Shared Kernel: Unlike VMs, containers share the host operating system's kernel. If an attacker escapes the container, they gain access to the underlying host OS.
  2. Vulnerable Images: Using container images downloaded from untrusted registries that contain known vulnerabilities or embedded backdoors.
  3. Default Privileges: Running containers with unnecessary root privileges (e.g., running Docker with --privileged).

Best Practices

  • Minimal Base Images: Use minimal OS images (like Alpine) to reduce the attack surface.
  • Non-Root Execution: Always configure the application to run as a non-root user inside the container.
  • Vulnerability Scanning: Scan container images for known vulnerabilities before deployment.