Snyk CLI Docker Plugin

9.6.5 · active · verified Wed Apr 22

The `snyk-docker-plugin` is a specialized component designed to extend the capabilities of the Snyk CLI, enabling it to detect vulnerabilities within Docker images. It currently stands at version 9.6.5 and exhibits a rapid release cadence, with multiple patches and minor versions released weekly or bi-weekly, indicating active development and maintenance. This plugin is crucial for scanning a wide array of Linux-based operating systems (Debian, Red Hat, Alpine, etc.), including distroless and scratch images, across various architectures (ARM, AMD, PPC). A key differentiator is its ability to identify vulnerabilities not only through package managers (rpm, apk, deb) but also by detecting Node and Java binaries installed outside of standard package management, and by analyzing Dockerfiles directly. It supports various image protocols and container registries, providing comprehensive security analysis for containerized applications.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates the installation of the Snyk CLI and how to use the `snyk container test` command with a local or remote Docker image to scan for vulnerabilities, including options for specifying a Dockerfile or excluding application vulnerabilities.

npm install -g snyk

# Authenticate your Snyk CLI with your Snyk account
snyk auth

# Build a sample Docker image (assuming you have a Dockerfile in your current directory)
# For example, create a Dockerfile with:
# FROM node:20-alpine
# WORKDIR /app
# COPY package*.json ./
# RUN npm install
# COPY . .
# CMD ["node", "server.js"]
docker build -t my-vulnerable-app:latest .

# Test your Docker image for vulnerabilities using the Snyk Docker plugin
snyk container test my-vulnerable-app:latest \
  --file=./Dockerfile \
  --exclude-app-vulns \
  --severity-threshold=high

# Alternatively, test a remote image from Docker Hub
snyk container test node:20-alpine

# Scan a local Docker archive
docker save -o my-app.tar my-vulnerable-app:latest
snyk container test --file=./my-app.tar

view raw JSON →