Docker Security Scanning เป็นขั้นตอนสำคัญใน DevSecOps Trivy เป็น Open-Source Scanner ที่ได้รับความนิยมมากที่สุด
ติดตั้งและใช้งาน Trivy
# ติดตั้ง:
# sudo apt install trivy หรือ brew install trivy
#
# Scan image:
# trivy image nginx:latest
# trivy image --severity CRITICAL,HIGH nginx:latest
# trivy image --format json -o results.json nginx:latest
#
# CI/CD Integration (GitHub Actions):
# uses: aquasecurity/trivy-action@master
# with:
# image-ref: myapp:latest
# exit-code: 1
# severity: CRITICAL,HIGH
#
# Best Practices:
# - Scan ทุก Build ใน CI/CD
# - ใช้ Minimal Base Image (Alpine, Distroless)
# - Multi-Stage Build แยก Build/Runtime
# - Pin Versions ไม่ใช้ latest tag
# - Rebuild Image เป็นประจำ
สรุป
Docker Security Scanning ด้วย Trivy เป็นขั้นตอนที่ง่ายแต่สำคัญมาก ใส่ใน CI/CD Pipeline Scan ทุก Build
