In short
A container image often ships with a whole Linux userland you never asked for, plus any known bugs inside it. Securing containers means shrinking that, scanning it and limiting what it can do at runtime.
Securing containers means small, patched base images, image scanning in ECR, no secrets in images, non-root users and a narrow task or pod role for each workload.

Think of it like this
Airport baggage check
Before boarding, every bag goes through the X-ray. Banned items get pulled out. Even after that, passengers can't wander into the cockpit. Scan images before they ship, then give running containers only the access they need.
Watch it happen
Security at every step
1/5Start from a small base like a slim or distroless image. Fewer packages means fewer known vulnerabilities.
The big ideas
What you need to know
Smaller is safer
Multi-stage builds leave compilers and dev tools out of the final image.
Don't run as root
If an attacker breaks into a root container, escaping to the host gets easier.
Pin versions
Use exact tags or digests, not latest, so you know exactly what's running and what was scanned.
Per-pod identity
Use IRSA or EKS Pod Identity on AWS and Workload Identity on GKE, so each pod gets its own scoped cloud role.
See it in code
Walk through the code
1containers:2 - name: api3 image: registry.example.com/api:1.4.24 securityContext:5 runAsNonRoot: true6 runAsUser: 100017 allowPrivilegeEscalation: false8 readOnlyRootFilesystem: true9 capabilities:10 drop: ["ALL"]11 resources:12 limits: { cpu: "500m", memory: "256Mi" }1/4A pinned version from your own registry, not :latest from anywhere.
Part of a pod spec. Scan the image first with trivy image registry.example.com/api:1.4.2 in your CI.
Save yourself the pain
Common mistakes
Oops
Using a full OS image like ubuntu:latest for a small Node.js API.
Do this instead
Use a slim or distroless base and a multi-stage build. Your scan list gets much shorter.
Oops
Baking API keys into the image with ENV in the Dockerfile.
Do this instead
Anyone who pulls the image can read them. Inject secrets at runtime from a secrets store.
Your mission
Scan, shrink, rescan
Quick check
Which change reduces the number of vulnerabilities a scanner reports in your image?
Go deeper
- 1Turn on ECR scanning and fix the highest-severity finding in one of your images.
- 2Give an ECS task its own task role with only the permissions it needs.
- 3Pass secrets to the task from Secrets Manager instead of environment variables in code.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.