DEV Community

alphokung
alphokung

Posted on

Scan ช่องโหว่ Docker image ด้วย Trivy

ปัจจุบันการพัฒนาระบบโดยใช้ Container Technology แทบจะกลายเป็นท่ามาตรฐานไปแล้ว อย่างไรก็ตามเรื่องความปลอดภัยก็เป็นสิ่งที่พวกเรานักพัฒนามองข้ามไม่ได้เลย วันนี้มาลองดูกันว่า เราจะ Scan ช่องโหว่ของ Image ที่เราเขียนขึ้นมาด้วย Trivy ยังไงได้บ้าง

ติดตั้ง Trivy

เริ่มต้นจากการติดตั้ง Trivy ก่อน โดยสามารถติดตั้งผ่าน Homebrew ได้เลยดังนี้

brew install aquasecurity/trivy/trivy
Enter fullscreen mode Exit fullscreen mode

เมื่อติดตั้งแล้ว ลองใช้คำสั่ง trivy -v ดู ถ้าได้หน้าตาแบบนี้ถือว่าสำเร็จ

Image description

ทดสอบ Scan ช่องโหว่ดูหน่อย

ลอง pull image ซักตัวที่เราจะมา scan ช่องโหว่ดู ซึ่งในตัวอย่างนี้จะใช้ node:14-alpine

docker pull node:14-alpine
Enter fullscreen mode Exit fullscreen mode

Image description

จากนั้นทำการ Scan ช่องโหว่ด้วยคำสั่ง

trivy image node:14-alpine
Enter fullscreen mode Exit fullscreen mode

เพียงเท่านี้ก็ได้ผล Scan ออกมาแล้ว ซึ่งขั้นตอนถัดไป ก็ไปแก้ตาม Recommendation ที่มันบอกได้เลย

Image description

Happy coding ครับ :)

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay