Docker Image Scan (With Trivy)
ขั้นตอนการใช้งานบน Ubuntu 22.04 LTS
- ติดตั้ง trivy โดยรันคำสั่งติดตั้งดังนี้
sudo apt-get install wget apt-transport-https gnupg lsb-release wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add - echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list sudo apt-get update sudo apt-get install trivy
- หากต้องการตรวจสอบ container image ที่อยู่บน registry อื่นๆ ที่ไม่ใช่ docker hub ให้ทำการ pull มายังเครื่องที่ใช้ run คำสั่งก่อน ตัวอย่างเช่น
- เริ่มการ scan โดยระบุ container image (ในตัวอย่าง container image ชื่อ registry.in.psu.ac.th/docs/hrms:latest) และใช้ template ที่สร้าง report ในรูปแบบ HTML ไฟล์ ด้วยคำสั่งดังนี้
- จากคำสั่งด้านบนจะได้ผลลัพธ์เป็น ไฟล์ HTML ที่สามารถเปิดดูได้ด้วย browser ต่างๆ ดังรูป
- เมื่อทำการตรวจสอบเสร็จแล้วสามารถลบ container image ได้โดยใช้คำสั่ง