• Stars
    star
    290
  • Rank 142,981 (Top 3 %)
  • Language
    Shell
  • License
    Other
  • Created over 1 year ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Docker Scout CLI

Docker Scout

Docker Scout is a set of software supply chain features integrated into Docker's user interfaces and command line interface (CLI). These features offer comprehensive visibility into the structure and security of container images. This repository contains installable binaries of the docker scout CLI plugin.

Usage

The CLI documentation is available in this repository.

See the reference documentation to learn about Docker Scout including Docker Desktop and Docker Hub integrations.

Environment Variables

The following environment variables are availabe to configure the Scout CLI:

Name Description
DOCKER_SCOUT_CACHE_FORMAT Format of the local image cache; can be oci or tar
DOCKER_SCOUT_CACHE_DIR Directory where the local SBOM cache is stored
DOCKER_SCOUT_NO_CACHE Disable the local SBOM cache
DOCKER_SCOUT_REGISTRY_TOKEN Registry Access token to authenticate when pulling images
DOCKER_SCOUT_REGISTRY_USER Registry user name to authenticate when pulling images
DOCKER_SCOUT_REGISTRY_PASSWORD Registry password/PAT to authenticate when pulling images
DOCKER_SCOUT_HUB_USER Docker Hub user name to authenticate against the Docker Scout backend
DOCKER_SCOUT_HUB_PASSWORD Docker Hub password/PAT to authenticate against the Docker Scout backend
DOCKER_SCOUT_OFFLINE Offline mode during SBOM indexing
DOCKER_SCOUT_NEW_VERSION_WARN Warn about new versions of the Docker Scout CLI
DOCKER_SCOUT_EXPERIMENTAL_WARN Warn about experimental features
DOCKER_SCOUT_EXPERIMENTAL_POLICY_OUTPUT Disable experimental policy output

CLI Plugin Installation

Docker Desktop

docker scout CLI plugin is available by default on Docker Desktop starting with version 4.17.

Manual Installation

To install it manually:

  • Download the docker-scout binary corresponding to your platform from the latest or other releases.
  • Uncompress it as
    • docker-scout on Linux and macOS
    • docker-scout.exe on Windows
  • Copy the binary to the scout directory
    • $HOME/.docker/scout on Linux and macOS
    • %USERPROFILE%\.docker\scout on Windows
  • Make it executable on Linux and macOS
    • chmod +x $HOME/.docker/scout/docker-scout
  • Authorize the binary to be executable on macOS
    • xattr -d com.apple.quarantine $HOME/.docker/scout/docker-scout
  • Add the scout directory to your .docker/config.json as a plugin directory
    • $HOME/.docker/config.json on Linux and macOS
    • %USERPROFILE%\.docker\config.json on Windows
    • Add the cliPluginsExtraDirs property to the config.json file
{
	...
	"cliPluginsExtraDirs": [
		<full path to the .docker/scout folder>
	],
	...
}

Script Installation

To install, run the following command in your terminal:

curl -sSfL https://raw.githubusercontent.com/docker/scout-cli/main/install.sh | sh -s --

Run as container

A container image to run the Docker Scout CLI in containerized environments is available at docker/scout-cli.

CI Integration

Docker Scout CLI can be used in CI environments. See below for the various ways to integrate the CLI into your CI pipelines.

GitHub Action

An early prototype of running the Docker Scout CLI as part of a GitHub Action workflow is available at docker/scout-action.

The following GitHub Action workflow can be used as a template to integrate Docker Scout:

name: Docker

on:
  push:
    tags: [ "*" ]
    branches:
      - 'main'
  pull_request:
    branches: [ "**" ]
    
env:
  # Use docker.io for Docker Hub if empty
  REGISTRY: docker.io
  IMAGE_NAME: ${{ github.repository }}
  SHA: ${{ github.event.pull_request.head.sha || github.event.after }}

jobs:
  build:

    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
        with:
          ref: ${{ env.SHA }}
          
      - name: Setup Docker buildx
        uses: docker/[email protected]

      # Login against a Docker registry except on PR
      # https://github.com/docker/login-action
      - name: Log into registry ${{ env.REGISTRY }}
        uses: docker/[email protected]
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ secrets.DOCKER_USER }}
          password: ${{ secrets.DOCKER_PAT }}

      # Extract metadata (tags, labels) for Docker
      # https://github.com/docker/metadata-action
      - name: Extract Docker metadata
        id: meta
        uses: docker/[email protected]
        with:
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
          labels: |
            org.opencontainers.image.revision=${{ env.SHA }}
          tags: |
            type=edge,branch=$repo.default_branch
            type=semver,pattern=v{{version}}
            type=sha,prefix=,suffix=,format=short
      
      # Build and push Docker image with Buildx (don't push on PR)
      # https://github.com/docker/build-push-action
      - name: Build and push Docker image
        id: build-and-push
        uses: docker/[email protected]
        with:
          context: .
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          cache-from: type=gha
          cache-to: type=gha,mode=max
      
      - name: Docker Scout
        id: docker-scout
        if: ${{ github.event_name == 'pull_request' }}
        uses: docker/scout-action@dd36f5b0295baffa006aa6623371f226cc03e506
        with:
          command: cves
          image: ${{ steps.meta.outputs.tags }}
          only-severities: critical,high
          exit-code: true

GitLab

Use the following pipeline definition as a template to get Docker Scout integrated in GitLab CI:

docker-build:
  image: docker:latest
  stage: build
  services:
    - docker:dind
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
    
    # Install curl and the Docker Scout CLI
    - |
      apk add --update curl
      curl -sSfL https://raw.githubusercontent.com/docker/scout-cli/main/install.sh | sh -s -- 
      apk del curl 
      rm -rf /var/cache/apk/* 
    # Login to Docker Hub required for Docker Scout CLI
    - echo "$DOCKER_HUB_PAT" | docker login --username "$DOCKER_HUB_USER" --password-stdin
  script:
    - |
      if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
        tag=""
        echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
      else
        tag=":$CI_COMMIT_REF_SLUG"
        echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
      fi
    - docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" .
    
    - |
      if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
        # Get a CVE report for the built image and fail the pipeline when critical or high CVEs are detected
        docker scout cves "$CI_REGISTRY_IMAGE${tag}" --exit-code --only-severity critical,high    
      else
        # Compare image from branch with latest image from the default branch and fail if new critical or high CVEs are detected
        docker scout compare "$CI_REGISTRY_IMAGE${tag}" --to "$CI_REGISTRY_IMAGE:latest" --exit-code --only-severity critical,high --ignore-unchanged
      fi
    
    - docker push "$CI_REGISTRY_IMAGE${tag}"
  rules:
    - if: $CI_COMMIT_BRANCH
      exists:
        - Dockerfile

CircleCI

Use the following pipeline definition as a template to get Docker Scout integrated in CircleCI project:

version: 2.1

jobs:
  
  build:

    docker:
      - image: cimg/base:stable
    
    environment:
      IMAGE_TAG: docker/scout-demo-service:latest
    
    steps:
      # Checkout the repository files
      - checkout

      # Set up a separate Docker environment to run `docker` commands in
      - setup_remote_docker:
          version: 20.10.24

      # Install Docker Scout and login to Docker Hub
      - run:
          name: Install Docker Scout
          command: |
            env
            curl -sSfL https://raw.githubusercontent.com/docker/scout-cli/main/install.sh | sh -s -- -b /home/circleci/bin
            echo $DOCKER_HUB_PAT | docker login -u $DOCKER_HUB_USER --password-stdin

      # Build the Docker image
      - run:
          name: Build Docker image
          command: docker build -t $IMAGE_TAG .
      
      # Run Docker Scout          
      - run:
          name: Scan image for CVEs
          command: |
            docker-scout cves $IMAGE_TAG --exit-code --only-severity critical,high

workflows:
  build-docker-image:
    jobs:
      - build

Microsoft Azure DevOps Pipelines

Use the following pipeline definition as a template to get Docker Scout integrated in Azure DevOps Pipelines:

trigger:
- main

resources:
- repo: self

variables:
  tag: '$(Build.BuildId)'
  image: 'vonwig/nodejs-service'

stages:
- stage: Build
  displayName: Build image
  jobs:
  - job: Build
    displayName: Build
    pool:
      vmImage: ubuntu-latest
    steps:
    - task: Docker@2
      displayName: Build an image
      inputs:
        command: build
        dockerfile: '$(Build.SourcesDirectory)/Dockerfile'
        repository: $(image)
        tags: |
          $(tag)
    - task: CmdLine@2
      displayName: Find CVEs on image
      inputs:
        script: |
          # Install the Docker Scout CLI
          curl -sSfL https://raw.githubusercontent.com/docker/scout-cli/main/install.sh | sh -s --
          # Login to Docker Hub required for Docker Scout CLI
          docker login -u $(DOCKER_HUB_USER) -p $(DOCKER_HUB_PAT)
          # Get a CVE report for the built image and fail the pipeline when critical or high CVEs are detected
          docker scout cves $(image):$(tag) --exit-code --only-severity critical,high

Jenkins

The following snippet can be added to a Jenkinsfile to install and analyze images:

        stage('Analyze image') {
            steps {
                // Install Docker Scout
                sh 'curl -sSfL https://raw.githubusercontent.com/docker/scout-cli/main/install.sh | sh -s -- -b /usr/local/bin'
                
                // Log into Docker Hub
                sh 'echo $DOCKER_HUB_PAT | docker login -u $DOCKER_HUB_USER --password-stdin'

                // Analyze and fail on critical or high vulnerabilities
                sh 'docker-scout cves $IMAGE_TAG --exit-code --only-severity critical,high'
            }
        }

This example assume two secrets to be available to authenticate against Docker Hub, called DOCKER_HUB_USER and DOCKER_HUB_PAT.

Bitbucket

Use the following pipeline definition as a template to get Docker Scout integrated in Bitbucket Pipelines:

image: docker

pipelines:
  default:
    - step:
        name: Build
        services:
          - docker
        caches:
          - docker
        script:
          - echo "$DOCKER_HUB_PAT" | docker login --username "$DOCKER_HUB_USER" --password-stdin $CI_REGISTRY

          # Install curl and the Docker Scout CLI
          - |
            export DOCKER_BUILDKIT=0
            apk add --update curl
            curl -sSfL https://raw.githubusercontent.com/docker/scout-cli/main/install.sh | sh -s -- 
            apk del curl 
            rm -rf /var/cache/apk/* 
          # Login to Docker Hub required for Docker Scout CLI
          - echo "$DOCKER_HUB_PAT" | docker login --username "$DOCKER_HUB_USER" --password-stdin

          - |
            export DEVELOPMENT_BRANCH="main"
            if [[ "$BITBUCKET_BRANCH" == "$DEVELOPMENT_BRANCH" ]]; then # Bitbucket uses master by default, adjust if your default branch is different
              tag=":latest"
              echo "Running on default branch '$DEVELOPMENT_BRANCH': tag = 'latest'"
            else
              tag=":$BITBUCKET_COMMIT"
              echo "Running on branch '$BITBUCKET_BRANCH': tag = $tag"
            fi
          - docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" .

          - |
            if [[ "$BITBUCKET_BRANCH" == "$DEVELOPMENT_BRANCH" ]]; then
              # Get a CVE report for the built image and fail the pipeline when critical or high CVEs are detected
              docker scout cves "$CI_REGISTRY_IMAGE${tag}" --exit-code --only-severity critical,high    
            else
              # Compare image from branch with latest image from the default branch and fail if new critical or high CVEs are detected            
              docker scout compare "$CI_REGISTRY_IMAGE${tag}" --to "$CI_REGISTRY_IMAGE:latest" --exit-code --only-severity critical,high --ignore-unchanged
            fi
          - docker push "$CI_REGISTRY_IMAGE${tag}"

definitions:
  services:
    docker:
      memory: 2048 # Optional: Increase if needed

This example assumes two secrets to be available to authenticate against Docker Hub, called DOCKER_HUB_USER and DOCKER_HUB_PAT, also is necessary more two secrets called CI_REGISTRY, CI_REGISTRY_IMAGE about registry info.

License

The Docker Scout CLI is licensed under the Terms and Conditions of the Docker Subscription Service Agreement.

More Repositories

1

awesome-compose

Awesome Docker Compose samples
HTML
34,762
star
2

compose

Define and run multi-container applications with Docker
Go
33,472
star
3

kitematic

Visual Docker Container Management on Mac & Windows
JavaScript
12,247
star
4

labs

This is a collection of tutorials for learning how to use Docker with various tools. Contributions welcome.
PHP
11,518
star
5

docker-bench-security

The Docker Bench for Security is a script that checks for dozens of common best-practices around deploying Docker containers in production.
Shell
9,038
star
6

dockercraft

Docker + Minecraft = Dockercraft
Lua
7,185
star
7

docker-py

A Python library for the Docker Engine API
Python
6,800
star
8

machine

Machine management for a container-centric world
Go
6,628
star
9

cli

The Docker CLI
Go
4,850
star
10

build-push-action

GitHub Action to build and push Docker images with Buildx
TypeScript
4,242
star
11

docs

Source repo for Docker's Documentation
Markdown
4,163
star
12

genai-stack

Langchain + Docker + Neo4j + Ollama
Python
3,907
star
13

buildx

Docker CLI plugin for extended build capabilities with BuildKit
Go
3,513
star
14

getting-started

Getting started with Docker
JavaScript
2,911
star
15

libchan

Like Go channels over the network
Go
2,470
star
16

for-mac

Bug reports for Docker Desktop for Mac
2,426
star
17

docker-install

Docker installation script
Shell
2,281
star
18

for-win

Bug reports for Docker Desktop for Windows
1,849
star
19

roadmap

Welcome to the Public Roadmap for All Things Docker! We welcome your ideas.
1,734
star
20

app

Make your Docker Compose applications reusable, and share them on Docker Hub
Go
1,575
star
21

compose-on-kubernetes

Deploy applications described in Compose onto Kubernetes clusters
Go
1,419
star
22

docker-credential-helpers

Programs to keep Docker login credentials safe by storing in platform keystores
Go
1,060
star
23

login-action

GitHub Action to login against a Docker registry
TypeScript
1,029
star
24

setup-buildx-action

GitHub Action to set up Docker Buildx
TypeScript
933
star
25

metadata-action

GitHub Action to extract metadata (tags, labels) from Git reference and GitHub events for Docker
TypeScript
888
star
26

libkv

Distributed key/value store abstraction library
Go
854
star
27

for-linux

Docker Engine for Linux
751
star
28

libcompose

*Unmaintained/Deprecated* An experimental go library providing Compose-like functionality
Go
585
star
29

setup-qemu-action

GitHub Action to install QEMU static binaries
TypeScript
431
star
30

welcome-to-docker

JavaScript
422
star
31

go-plugins-helpers

Go helper packages to extend the Docker Engine
Go
331
star
32

hub-tool

🧪 Docker Hub experimental CLI tool
Go
330
star
33

community

326
star
34

engine-api

DEPRECATED: Please see https://github.com/docker/docker/tree/master/client
Go
265
star
35

hub-feedback

Feedback and bug reports for the Docker Hub
233
star
36

doodle

A Home for Docker Doodles
Go
221
star
37

go-units

Parse and print size and time units in human-readable format
Go
215
star
38

go-connections

Utility package to work with network connections
Go
212
star
39

compose-switch

Go
199
star
40

go-docker

(Still WIP) Official Go SDK for Docker
Go
189
star
41

scan-cli-plugin

Docker Scan is a Command Line Interface to run vulnerability detection on your Dockerfiles and Docker images
Go
181
star
42

bake-action

GitHub Action to use Docker Buildx Bake as a high-level build command
TypeScript
176
star
43

gordon

Cli application to manage github pull requests
Go
176
star
44

docker-ce-packaging

Packaging scripts for Docker CE
Makefile
174
star
45

github-actions

⚠️ This repository is deprecated and has been replaced by docker/build-push-action@v2
Go
163
star
46

sbom-cli-plugin

Plugin for Docker CLI to support SBOM creation using Syft
Go
153
star
47

extensions-sdk

Desktop Extensions SDK
142
star
48

hacktoberfest-2022

Docker Hacktoberfest 2022
140
star
49

go-events

Composable event distribution for Go
Go
131
star
50

node-sdk

Docker CLI gRPC JavaScript SDK
JavaScript
110
star
51

libtrust

Primitives for identity and authorization
Go
107
star
52

compose-ecs

Deploy compose application on ECS
Go
100
star
53

golang-cross

Dockerfile
97
star
54

getting-started-app

A simple application for the getting started guide in Docker's documentation
JavaScript
93
star
55

multi-container-app

EJS
88
star
56

volumes-backup-extension

Back up, clone, restore, and share Docker volumes effortlessly.
PLpgSQL
87
star
57

go-metrics

Package for metrics collection in Docker projects
Go
87
star
58

scout-action

Docker Scout GitHub Action
JavaScript
78
star
59

desktop-linux

Bug reports for Docker Desktop for Linux
76
star
60

containerd-packaging

Linux distro packaging for containerd
Shell
68
star
61

opensource

Contains documentation and scripts related to the management of Open Source at Docker
Go
63
star
62

dev-environments

63
star
63

actions-toolkit

Toolkit for Docker (GitHub) Actions
TypeScript
58
star
64

extension-ideas

A place to suggest new ideas for Docker Extensions and get new ideas of what to build for the larger Docker community
48
star
65

binfmt

Please use https://github.com/linuxkit/linuxkit/tree/master/pkg/binfmt instead of this repo
Go
44
star
66

dev-envs-extension

TypeScript
40
star
67

code-of-conduct

40
star
68

index-cli-plugin

Go
40
star
69

whalesay

A repository in support of the Docker's official whalesay image
Perl
39
star
70

labs-make-runbook

TypeScript
38
star
71

HttpOverStream

.NET library for using HTTP 1.1 over streams, especially Windows Named Pipes
C#
33
star
72

scout-demo-service

Dockerfile
33
star
73

buildkit-syft-scanner

BuildKit Syft scanner
Go
23
star
74

get-involved

Get Involved with Docker
CSS
23
star
75

getting-started-todo-app

Sample application to get started with Docker
JavaScript
23
star
76

babashka-pod-docker

Go
20
star
77

packaging

Docker Packaging (apk, deb, rpm, static)
Dockerfile
20
star
78

buildx-desktop

19
star
79

cli-docs-tool

Utilities to generate (reference) documentation for the docker CLI
Go
19
star
80

docker-nodejs-sample

A simple Node.js application for the guide in Docker's documentation
JavaScript
18
star
81

go

Go packages with small patches autogenerated (used for canonical/json)
Go
18
star
82

base-cli-plugin

Experimental Docker CLI plugin to detect base images
Go
16
star
83

notary-official-images

Shell
16
star
84

python-docker

A simple Python app for the Python Language Guide in Docker's Docs
Python
16
star
85

go-imageinspect

Go
15
star
86

docker-dotnet-sample

A simple .NET web application
HTML
14
star
87

github-actions-runner

Docker's containerized github-actions runner
Shell
13
star
88

labs-ai-tools-for-devs

Project AI For Devs (chat-sdlc) - AI agents running containerized tools
Clojure
13
star
89

dc23-secure-workshop

DockerCon 2023 Secure Development with Docker hands-on exercises code
Dockerfile
11
star
90

extensions-submissions

Submit your Docker Extension here
Shell
11
star
91

docker-php-sample

A simple PHP application
PHP
10
star
92

docker-vscode

The Docker VSCode EAP is an extension for VSCode which provides an early preview into new features by Docker.
10
star
93

python-docker-dev

A simple Python app for the Python Language Guide in Docker's Docs
Python
10
star
94

import-restrictions

Restrict imports in your go project
Go
9
star
95

desktop-action

Docker Desktop action
9
star
96

labs-tape

Tape is for packaging applications
Go
8
star
97

engine-sync

Sync moby/moby with docker/engine
Shell
8
star
98

database-extension

TypeScript
7
star
99

bindmount-apps

EJS
7
star
100

compose-desktop

5
star