π³Basic Container Security Labs
π― Objective
π§° Prerequisites
πΉ Lab 1: Use Minimal Base Images
Step 1: Compare image sizes
docker pull ubuntu
docker pull alpine
docker images | grep -E 'ubuntu|alpine'ubuntu latest a0e45e2ce6e6 12 days ago 78.1MB
alpine latest aded1e1a5b37 2 months ago 7.83MBπΉ Lab 2: Run Containers as Root User
Step 1: Create a Dockerfile
Step 2: Build and run
πΉ Lab 3: Run Containers as Non-Root User
Step 1: Create a more secure Dockerfile
Step 2: Build and run again
πΉ Lab 4: Drop Unnecessary Capabilities
Step 1: Run a minimal-capabilities container
πΉ Lab 5: Use Seccomp to Restrict Syscalls
Step 1: Run with Dockerβs default seccomp profile
πΉ Lab 6: Apply AppArmor Profiles
Step 1: View active profiles
Step 2: Run with a profile
πΉ Lab 7: Secure Secrets Handling
Step 1: Avoid baking secrets into images
Step 2: Use runtime secrets
πΉ Lab 8: Scan Images for Vulnerabilities
Step 1: Use Trivy or Docker Scout
Step 2: Scan the Alpine image
Step 3: Scan the Ubuntu image
β
Wrap-Up
Last updated