Docker & ContainersOptional

Image Security & Slimming

Harden and shrink images for production.

30 min read advanced 3 objectives

Status

Not started

What you will learn

  • Run as non-root
  • Scan for vulnerabilities
  • Pin and minimize bases

New to this? Start here

The basics, in plain English

Images can carry security holes, especially if they include things you do not need. Hardening means trimming an image down and running it carefully so attackers have fewer ways in.

Hardening
Making something more secure by removing risk and locking it down.
Non-root user
Running the app as a limited account, so a break-in cannot take over everything.
Vulnerability
A known weakness in software that an attacker could exploit.
Scanning
Automatically checking an image for known vulnerabilities before shipping.
Minimal base
Starting from the smallest possible image so there is less to attack.
01

Least privilege

Use a non-root USER, pin base image digests, and scan with trivy. Distroless and Alpine cut the attack surface.

Finished this topic?

Mark it done to earn 100 XP and keep your streak alive.