Skip to content
KitploitKITPLOIT
ツールブログ
提出
ツールブログ
提出

ハッキング、侵入テスト、サイバーセキュリティツールをあなたのセキュリティアーセナルに!

Kitploitはハッキング、サイバーセキュリティ、ペネトレーションテストのツールディレクトリです。最新のプロジェクトアップデートを見つけて、脆弱性の発見、システム分析、テストの自動化、セキュリティの強化を行いましょう。

··フィード·お問い合わせ·プライバシー·© 2026 Kitploit

ツールディレクトリ

カテゴリ

すべてのカテゴリを見る
Loading categories
dockle — コンテナイメージのセキュリティリンター、ベストプラクティスのDockerイメージ構築を支援、簡単に始められます | Kitploit
ツール/GitHubGitHub/goodwithtech/dockle
脆弱性スキャナーコンテナセキュリティ構成監査DevSecOps
GitHubgoodwithtech/dockle

dockle

コンテナイメージのセキュリティリンター、ベストプラクティスのDockerイメージ構築を支援、簡単に始められます

リポジトリを見るウェブサイト
3.3k1661ヶ月前Kitploit レビュー済み

人気

すべて見る →

コミュニティで最も使われているツールを見つけましょう。

すべてのツールを探索

ツールコレクションを閲覧

すべてのツールを見る →
共有

Financial Contributors on Open Collective GitHub release CircleCI Go Report Card License: AGPL v3

Dockle - コンテナイメージのセキュリティLinter、ベストプラクティスなDockerイメージの構築を支援、すぐに始められます

Dockle は以下を支援します:

  1. ベストプラクティスに従ったDockerイメージの構築
  2. 安全なDockerイメージの構築
    • チェックポイントは CIS Benchmarks に準拠```bash $ brew untap goodwithtech/dockle # who use 0.1.16 or older version $ brew install goodwithtech/r/dockle $ dockle [YOUR_IMAGE_NAME]
root@kitploit:~
「[インストール](#installation)」と「[一般的な例](#common-examples)」を参照してください。

<img src="https://assets.kitploit.com/production/public/readmes/4137/343598bd4d53296c6d6d23acde8c2917d5727f03e7b3a34c1ff0865c435bb974.png" width="800">

# チェックポイントの比較

<img src="https://assets.kitploit.com/production/public/readmes/4137/4f4835c3a5fd70f436d9d8ea656fd8a521112fece4e35977288064d3f6f4510a.png" width="800">
<img src="https://assets.kitploit.com/production/public/readmes/4137/7bee9da0b061957af6a175a3b975dca82813c27f72ab6921dfe8ab2d6747322b.png" width="800">

# 目次

- [機能](#features)
- [比較](#comparison)
- [インストール](#installation)
  - [Homebrew(Mac OS X / Linux および WSL)](#homebrew-mac-os-x--linux-and-wsl)
  - [RHEL/CentOS](#rhelcentos)
  - [Debian/Ubuntu](#debianubuntu)
  - [Arch Linux](#arch-linux)
  - [Windows](#windows)
  - [Microsoft PowerShell 7](#microsoft-powershell-7)
  - [バイナリ](#binary)
  - [asdf](#asdf)
  - [mise](#mise)
  - [ソースから](#from-source)
  - [Docker を使用](#use-docker)
- [クイックスタート](#quick-start)
  - [基本](#basic)
  - [Docker](#docker)
- [チェックポイントの概要](#checkpoint-summary)
- [一般的な例](#common-examples)
  - [イメージのスキャン](#scan-an-image)
  - [イメージファイルのスキャン](#scan-an-image-file)
  - [JSON 形式で結果を取得または保存](#get-or-save-the-results-as-json)
  - [SARIF 形式で結果を取得または保存](#get-or-save-the-results-as-sarif)
  - [終了コードの指定](#specify-exit-code)
  - [終了レベルの指定](#specify-exit-level)
  - [指定したチェックポイントを無視](#ignore-the-specified-checkpoints)
  - [不審な `環境変数` / `ファイル` / `ファイル拡張子` を受け入れる](#accept-suspicious-environment-variables--files--file-extensions)
  - [不審な `環境変数` / `ファイル` / `ファイル拡張子` を拒否](#reject-suspicious-environment-variables--files--file-extensions)
- [継続的インテグレーション(CI)](#continuous-integration-ci)
  - [GitHub Action](#github-action)
  - [Travis CI](#travis-ci)
  - [CircleCI](#circleci)
  - [GitLab CI](#gitlab-ci)
  - [プライベート Docker レジストリの認証](#authorization-for-private-docker-registry)
    - [Docker Hub](#docker-hub)
    - [Amazon ECR(Elastic Container Registry)](#amazon-ecr-elastic-container-registry)
    - [GCR(Google Container Registry)](#gcr-google-container-registry)
    - [セルフホストレジストリ(BasicAuth)](#self-hosted-registry-basicauth)
- [コントリビューター](#contributors)
  - [コードコントリビューター](#code-contributors)
  - [資金提供者](#financial-contributors)
    - [個人](#individuals)
    - [組織](#organizations)
- [ライセンス](#license)
- [著者](#author)

# 機能

- コンテナの脆弱性を検出
- ベストプラクティスの Dockerfile 作成を支援
- シンプルな使い方
  - イメージ名のみを指定
  - 「[クイックスタート](#quick-start)」と「[一般的な例](#common-examples)」を参照
- CIS ベンチマーク対応
  - 高精度
- DevSecOps
  - Travis CI、CircleCI、Jenkins などの CI に最適
  - 「[CI の例](#continuous-integration-ci)」を参照

# 比較

|  | [Dockle](https://github.com/goodwithtech/dockle) | [Hadolint](https://github.com/hadolint/hadolint) | [Docker Bench for Security](https://github.com/docker/docker-bench-security) | [Clair](https://github.com/coreos/clair) |
|--- |---:|---:|---:|---:|
| 対象 | イメージ | Dockerfile | ホスト<br/>Docker デーモン<br/>イメージ<br/>コンテナランタイム | イメージ |
| 実行方法 | バイナリ | バイナリ | シェルスクリプト | バイナリ |
| 依存関係 | なし | なし | 一部依存あり | なし |
| CI での利用 | ✓ | ✓ | × | × | 
| 目的 | セキュリティ監査<br/>Dockerfile Lint | Dockerfile Lint | セキュリティ監査<br/>Dockerfile Lint | 脆弱性スキャン |

# インストール

## Homebrew(Mac OS X / Linux および WSL)

[Mac OS X](https://brew.sh/) または [Linux と WSL(Windows Subsystem for Linux)](https://docs.brew.sh/Homebrew-on-Linux) で Homebrew を使用できます。```bash
$ brew install goodwithtech/r/dockle

RHEL/CentOS```bash

VERSION=$( curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" |
grep '"tag_name":' |
sed -E 's/."v([^"]+)"./\1/'
) && rpm -ivh https://github.com/goodwithtech/dockle/releases/download/v${VERSION}/dockle_${VERSION}_Linux-64bit.rpm

root@kitploit:~
## Debian/Ubuntu```bash
VERSION=$(
 curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" | \
 grep '"tag_name":' | \
 sed -E 's/.*"v([^"]+)".*/\1/' \
) && curl -L -o dockle.deb https://github.com/goodwithtech/dockle/releases/download/v${VERSION}/dockle_${VERSION}_Linux-64bit.deb
$ sudo dpkg -i dockle.deb && rm dockle.deb

Arch Linux

dockle は、Arch User Repository から dockle または dockle-bin パッケージを使ってインストールできます。``` git clone https://aur.archlinux.org/dockle-bin.git cd dockle-bin makepkg -sri

root@kitploit:~
## Windows```bash
VERSION=$(
 curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" | \
 grep '"tag_name":' | \
 sed -E 's/.*"v([^"]+)".*/\1/' \
) && curl -L -o dockle.zip https://github.com/goodwithtech/dockle/releases/download/v${VERSION}/dockle_${VERSION}_Windows-64bit.zip
$ unzip dockle.zip && rm dockle.zip
$ ./dockle.exe [IMAGE_NAME]

Microsoft PowerShell 7```bash

if (((Invoke-WebRequest "https://api.github.com/repos/goodwithtech/dockle/releases/latest").Content) -match '"tag_name":"v(?[^"]+)"') { $VERSION=$Matches.ver && Invoke-WebRequest "https://github.com/goodwithtech/dockle/releases/download/v${VERSION}/dockle_${VERSION}_Windows-64bit.zip" -OutFile dockle.zip && Expand-Archive dockle.zip && Remove-Item dockle.zip }

root@kitploit:~
## バイナリ

最新バージョンのバイナリは[リリースページ](https://github.com/goodwithtech/dockle/releases/latest)から入手できます。

ご自身のオペレーティングシステム/アーキテクチャ向けのアーカイブファイルをダウンロードしてください。アーカイブを解凍し、バイナリを`$PATH`が通っている場所(UNIX系システムでは`/usr/local/bin`など)に配置します。

- 注:実行権限が有効になっていることを確認してください。(`chmod +x dockle`)

## asdf

dockleは[asdfバージョンマネージャー](https://asdf-vm.com/)と、この[プラグイン](https://github.com/mathew-fleisch/asdf-dockle)を使用してインストールできます。これにより、GitHubリリースバイナリのさまざまなバージョンのインストール(および切り替え)が自動化されます。asdfが既にインストールされている場合、以下のコマンドを実行してdockleをインストールします:```bash
# Add dockle plugin
asdf plugin add dockle

# Show all installable versions
asdf list-all dockle

# Install specific version
asdf install dockle latest

# Set a version globally (on your ~/.tool-versions file)
asdf global dockle latest

# Now dockle commands are available
dockle --version

mise

mise(多言語ツールバージョンマネージャー)を使ってdockleをインストールできます。miseがすでにインストールされている場合、以下のコマンドを実行してdockleをインストールしてください:```bash

Show all installable versions

mise ls-remote dockle

Install specific version

mise install dockle@latest

Set a version globally

mise use -g dockle@latest

Now dockle commands are available

dockle --version

root@kitploit:~
## ソースから```bash
$ GO111MODULE=off go get github.com/goodwithtech/dockle/cmd/dockle
$ cd $GOPATH/src/github.com/goodwithtech/dockle && GO111MODULE=on go build -o $GOPATH/bin/dockle cmd/dockle/main.go

Dockerを使用する

また、Docker HubにDockleイメージがあります。コマンドをインストールする前にdockleを試すことができます。``` $ VERSION=$( curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" |
grep '"tag_name":' |
sed -E 's/."v([^"]+)"./\1/'
) && docker run --rm -v /var/run/docker.sock:/var/run/docker.sock
goodwithtech/dockle:v${VERSION} [YOUR_IMAGE_NAME]

root@kitploit:~
`-v /var/run/docker.sock:/var/run/docker.sock` は、ホストマシン上のイメージをスキャンしたい場合にのみ必要です。

# クイックスタート

## 基本

イメージ名(およびタグ)を指定するだけです。```bash
$ dockle [YOUR_IMAGE_NAME]
結果``` FATAL - CIS-DI-0009: Use COPY instead of ADD in Dockerfile * Use COPY : /bin/sh -c #(nop) ADD file:81c0a803075715d1a6b4f75a29f8a01b21cc170cfc1bff6702317d1be2fe71a3 in /app/credentials.json FATAL - CIS-DI-0010: Do not store credential in ENVIRONMENT vars/files * Suspicious filename found : app/credentials.json FATAL - DKL-DI-0005: Clear apt-get caches * Use 'rm -rf /var/lib/apt/lists' after 'apt-get install' : /bin/sh -c apt-get update && apt-get install -y git FATAL - DKL-LI-0001: Avoid empty password * No password user found! username : nopasswd WARN - CIS-DI-0001: Create a user for the container * Last user should not be root INFO - CIS-DI-0005: Enable Content trust for Docker * export DOCKER_CONTENT_TRUST=1 before docker pull/build INFO - CIS-DI-0008: Confirm safety of setuid/setgid files * setuid file: app/suid.txt urw-r--r-- * setgid file: app/gid.txt grw-r--r-- * setuid file: usr/bin/gpasswd urwxr-xr-x * setgid file: usr/bin/wall grwxr-xr-x * setuid file: bin/su urwxr-xr-x * setuid file: bin/umount urwxr-xr-x * setuid file: bin/mount urwxr-xr-x * setgid file: usr/bin/ssh-agent grwxr-xr-x * setuid file: etc/shadow urw-r----- * setuid file: usr/bin/chsh urwxr-xr-x * setuid file: usr/bin/chfn urwxr-xr-x * setuid file: usr/lib/openssh/ssh-keysign urwxr-xr-x * setgid file: etc/passwd grw-r--r-- * setgid file: sbin/unix_chkpwd grwxr-xr-x * setgid file: usr/bin/chage grwxr-xr-x * setuid file: usr/bin/passwd urwxr-xr-x * setgid file: usr/bin/expiry grwxr-xr-x * setuid file: usr/bin/newgrp urwxr-xr-x IGNORE - CIS-DI-0006: Add HEALTHCHECK instruction to the container image
root@kitploit:~
</details>

## Docker

また、Dockerを使用して、以下のように`dockle`コマンドを使用することもできます。```bash
$ export DOCKLE_LATEST=$(
 curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" | \
 grep '"tag_name":' | \
 sed -E 's/.*"v([^"]+)".*/\1/' \
)
$ docker run --rm goodwithtech/dockle:v${DOCKLE_LATEST} [YOUR_IMAGE_NAME]
  • ホストマシン上のイメージをスキャンするには、docker.sock をマウントする必要があります。

    root@kitploit:~
    $ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock ...
    

画像ファイルをスキャンする```bash

$ docker save alpine:latest -o alpine.tar $ dockle --input alpine.tar

root@kitploit:~
### 結果をJSONとして取得または保存```bash
$ dockle -f json goodwithtech/test-image:v1
$ dockle -f json -o results.json goodwithtech/test-image:v1
結果```json { "summary": { "fatal": 6, "warn": 2, "info": 2, "pass": 7 }, "details": [ { "code": "CIS-DI-0001", "title": "Create a user for the container", "level": "WARN", "alerts": [ "Last user should not be root" ] }, { "code": "CIS-DI-0005", "title": "Enable Content trust for Docker", "level": "INFO", "alerts": [ "export DOCKER_CONTENT_TRUST=1 before docker pull/build" ] }, { "code": "CIS-DI-0006", "title": "Add HEALTHCHECK instruction to the container image", "level": "WARN", "alerts": [ "not found HEALTHCHECK statement" ] }, { "code": "CIS-DI-0008", "title": "Remove setuid and setgid permissions in the images", "level": "INFO", "alerts": [ "Found setuid file: usr/lib/openssh/ssh-keysign urwxr-xr-x" ] }, { "code": "CIS-DI-0009", "title": "Use COPY instead of ADD in Dockerfile", "level": "FATAL", "alerts": [ "Use COPY : /bin/sh -c #(nop) ADD file:81c0a803075715d1a6b4f75a29f8a01b21cc170cfc1bff6702317d1be2fe71a3 in /app/credentials.json " ] }, { "code": "CIS-DI-0010", "title": "Do not store secrets in ENVIRONMENT variables", "level": "FATAL", "alerts": [ "Suspicious ENV key found : MYSQL_PASSWD" ] }, { "code": "CIS-DI-0010", "title": "Do not store secret files", "level": "FATAL", "alerts": [ "Suspicious filename found : app/credentials.json " ] }, { "code": "DKL-DI-0002", "title": "Avoid sensitive directory mounting", "level": "FATAL", "alerts": [ "Avoid mounting sensitive dirs : /usr" ] }, { "code": "DKL-DI-0005", "title": "Clear apt-get caches", "level": "FATAL", "alerts": [ "Use 'rm -rf /var/lib/apt/lists' after 'apt-get install' : /bin/sh -c apt-get update \u0026\u0026 apt-get install -y git" ] }, { "code": "DKL-LI-0001", "title": "Avoid empty password", "level": "FATAL", "alerts": [ "No password user found! username : nopasswd" ] } ] } ```

結果をSARIFとして取得または保存する```bash

$ dockle -f sarif goodwithtech/test-image:v1 $ dockle -f sarif -o results.json goodwithtech/test-image:v1

root@kitploit:~
<details>
<summary>結果</summary>```json
{
  "version": "2.1.0",
  "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
  "runs": [
    {
      "tool": {
        "driver": {
          "name": "Dockle",
          "informationUri": "https://github.com/goodwithtech/dockle",
          "rules": [
            {
              "id": "CIS-DI-0009",
              "shortDescription": {
                "text": "Use COPY instead of ADD in Dockerfile"
              },
              "help": {
                "text": "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#CIS-DI-0009"
              }
            },
            {
              "id": "CIS-DI-0010",
              "shortDescription": {
                "text": "Do not store credential in ENVIRONMENT vars/files"
              },
              "help": {
                "text": "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#CIS-DI-0010"
              }
            },
            {
              "id": "DKL-DI-0005",
              "shortDescription": {
                "text": "Clear apt-get caches"
              },
              "help": {
                "text": "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#DKL-DI-0005"
              }
            },
            {
              "id": "DKL-LI-0001",
              "shortDescription": {
                "text": "Avoid empty password"
              },
              "help": {
                "text": "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#DKL-LI-0001"
              }
            },
            {
              "id": "CIS-DI-0005",
              "shortDescription": {
                "text": "Enable Content trust for Docker"
              },
              "help": {
                "text": "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#CIS-DI-0005"
              }
            },
            {
              "id": "CIS-DI-0008",
              "shortDescription": {
                "text": "Confirm safety of setuid/setgid files"
              },
              "help": {
                "text": "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#CIS-DI-0008"
              }
            },
            {
              "id": "CIS-DI-0001",
              "shortDescription": {
                "text": "Create a user for the container"
              },
              "help": {
                "text": "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#CIS-DI-0001"
              }
            },
            {
              "id": "CIS-DI-0006",
              "shortDescription": {
                "text": "Add HEALTHCHECK instruction to the container image"
              },
              "help": {
                "text": "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#CIS-DI-0006"
              }
            }
          ]
        }
      },
      "results": [
        {
          "ruleId": "CIS-DI-0009",
          "level": "error",
          "message": {
            "text": "Use COPY : /bin/sh -c #(nop) ADD file:81c0a803075715d1a6b4f75a29f8a01b21cc170cfc1bff6702317d1be2fe71a3 in /app/credentials.json "
          }
        },
        {
          "ruleId": "CIS-DI-0010",
          "level": "error",
          "message": {
            "text": "Suspicious filename found : app/credentials.json , Suspicious ENV key found : MYSQL_PASSWD"
          }
        },
        {
          "ruleId": "DKL-DI-0005",
          "level": "error",
          "message": {
            "text": "Use 'rm -rf /var/lib/apt/lists' after 'apt-get install' : /bin/sh -c apt-get update \u0026\u0026 apt-get install -y git"
          }
        },
        {
          "ruleId": "DKL-LI-0001",
          "level": "error",
          "message": {
            "text": "No password user found! username : nopasswd"
          }
        },
        {
          "ruleId": "CIS-DI-0005",
          "level": "note",
          "message": {
            "text": "export DOCKER_CONTENT_TRUST=1 before docker pull/build"
          }
        },
        {
          "ruleId": "CIS-DI-0008",
          "level": "note",
          "message": {
            "text": "setuid file: urwxr-xr-x usr/bin/newgrp, setgid file: grwxr-xr-x usr/bin/ssh-agent, setgid file: grwxr-xr-x usr/bin/expiry, setuid file: urwxr-xr-x usr/lib/openssh/ssh-keysign, setuid file: urwxr-xr-x bin/umount, setgid file: grwxr-xr-x usr/bin/chage, setuid file: urwxr-xr-x usr/bin/passwd, setgid file: grwxr-xr-x sbin/unix_chkpwd, setuid file: urwxr-xr-x usr/bin/chsh, setgid file: grwxr-xr-x usr/bin/wall, setuid file: urwxr-xr-x bin/ping, setuid file: urwxr-xr-x bin/su, setuid file: urwxr-xr-x usr/bin/chfn, setuid file: urwxr-xr-x usr/bin/gpasswd, setuid file: urwxr-xr-x bin/mount"
          }
        },
        {
          "ruleId": "CIS-DI-0001",
          "level": "none",
          "message": {
            "text": "Last user should not be root"
          }
        },
        {
          "ruleId": "CIS-DI-0006",
          "level": "none",
          "message": {
            "text": "not found HEALTHCHECK statement"
          }
        }
      ]
    }
  ]
}

終了コードの指定

デフォルトでは、Dockle は問題があってもコード 0 で終了します。

WARN または FATAL アラートが見つかった場合に非ゼロの終了コードで終了するには、--exit-code, -c オプションを使用します。```bash $ dockle --exit-code 1 [IMAGE_NAME]

root@kitploit:~
### 終了レベルの指定

デフォルトでは、`--exit-code` は `WARN` または `FATAL` レベルのアラートがある場合に実行されます。

`--exit-level, -l` オプションを使用してアラートレベルを変更します。`info`、`warn`、`fatal` のいずれかを設定できます。```bash
$ dockle --exit-code 1 --exit-level info [IMAGE_NAME]
$ dockle --exit-code 1 --exit-level fatal [IMAGE_NAME]

指定されたチェックポイントを無視する

--ignore, -i オプションは指定されたチェックポイントを無視できます。```bash $ dockle -i CIS-DI-0001 -i DKL-DI-0006 [IMAGE_NAME]

root@kitploit:~
または、`DOCKLE_IGNORES`:```
export DOCKLE_IGNORES=CIS-DI-0001,DKL-DI-0006
dockle [IMAGE_NAME]

または、.dockleignore ファイルを使用してください:```bash $ cat .dockleignore

set root to default user because we want to run nginx

CIS-DI-0001

Use latest tag because to check the image inside only

DKL-DI-0006

root@kitploit:~
### 疑わしい `environment variables` / `files` / `file extensions` を許可する```bash
# --accept-key value, --ak value             You can add acceptable keywords.
dockle -ak GPG_KEY -ak KEYCLOAK_VERSION [IMAGE_NAME]
or DOCKLE_ACCEPT_KEYS=GPG_KEY,KEYCLOAK_VERSION dockle [IMAGE_NAME]

# --accept-file value, --af value            You can add acceptable file names.
dockle -af id_rsa -af id_dsa [IMAGE_NAME]
or DOCKLE_ACCEPT_FILES=id_rsa,id_dsa dockle [IMAGE_NAME]

# --accept-file-extension value, --ae value  You can add acceptable file extensions.
dockle -ae pem -ae log [IMAGE_NAME]
or DOCKLE_ACCEPT_FILE_EXTENSIONS=pem,log dockle [IMAGE_NAME]

疑わしい environment variables / files / file extensions の拒否```bash

--sensitive-word value, --sw value You can add acceptable keywords.

dockle -sw PRIVATE [IMAGE_NAME] or DOCKLE_ACCEPT_KEYS=GPG_KEY,KEYCLOAK_VERSION dockle [IMAGE_NAME]

--sensitive-file value, --sf value You can add acceptable file names.

dockle -sf .env [IMAGE_NAME] or DOCKLE_REJECT_FILES=.env dockle [IMAGE_NAME]

--sensitive-file-extension value, --se value You can add acceptable file extensions.

dockle -se pfx [IMAGE_NAME] or DOCKLE_REJECT_FILE_EXTENSIONS=pfx dockle [IMAGE_NAME]

root@kitploit:~
## Continuous Integration (CI)

Travis CI / CircleCI で `Dockle` を使用してビルドしたイメージをスキャンできます。

以下の例では、警告が見つかった場合にテストが失敗します。

ただし、`.dockleignore` ファイルを使用して、指定したターゲットチェックポイントを無視することができます。

あるいは、結果を表示するだけでテストを失敗させたくない場合は、`dockle` コマンドで `--exit-code` を `0` に指定します。

### GitHub Action

[goodwithtech/dockle-action](https://github.com/goodwithtech/dockle-action) を提供しています。```yaml
- uses: goodwithtech/dockle-action@main
  with:
    image: 'target'
    format: 'list'
    exit-code: '1'
    exit-level: 'warn'
    ignore: 'CIS-DI-0001,DKL-DI-0006'

Travis CI

.travis.yml```yaml services: - docker

env: global: - COMMIT=${TRAVIS_COMMIT::8}

before_install:

  • docker build -t dockle-ci-test:${COMMIT} .
  • export VERSION=$(curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" | grep '"tag_name":' | sed -E 's/."v([^"]+)"./\1/')
  • wget https://github.com/goodwithtech/dockle/releases/download/v${VERSION}/dockle_${VERSION}_Linux-64bit.tar.gz
  • tar zxvf dockle_${VERSION}_Linux-64bit.tar.gz script:
  • ./dockle dockle-ci-test:${COMMIT}
  • ./dockle --exit-code 1 dockle-ci-test:${COMMIT}
root@kitploit:~
</details>

- 例: https://travis-ci.org/goodwithtech/dockle-ci-test
- リポジトリ: https://github.com/goodwithtech/dockle-ci-test

### CircleCI

<details>
<summary>.circleci/config.yml</summary>```yaml
jobs:
  build:
    docker:
      - image: docker:18.09-git
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Build image
          command: docker build -t dockle-ci-test:${CIRCLE_SHA1} .
      - run:
          name: Install dockle
          command: |
            apk add --update curl
            VERSION=$(
                curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" | \
                grep '"tag_name":' | \
                sed -E 's/.*"v([^"]+)".*/\1/'
            )
            wget https://github.com/goodwithtech/dockle/releases/download/v${VERSION}/dockle_${VERSION}_Linux-64bit.tar.gz
            tar zxvf dockle_${VERSION}_Linux-64bit.tar.gz
            mv dockle /usr/local/bin
      - run:
          name: Scan the local image with dockle
          command: dockle --exit-code 1 dockle-ci-test:${CIRCLE_SHA1}
workflows:
  version: 2
  release:
    jobs:
      - build
  • 例: https://circleci.com/gh/goodwithtech/dockle-ci-test
  • リポジトリ: https://github.com/goodwithtech/dockle-ci-test

GitLab CI

.gitlab-ci.yml```yaml image: docker:stable stages: - test

variables: DOCKER_HOST: tcp://docker:2375/ DOCKER_DRIVER: overlay2 services:

  • docker:dind

unit_test: stage: test before_script: - apk -Uuv add bash git curl tar sed grep script: - docker build -t dockle-ci-test:${CI_COMMIT_SHORT_SHA} . - | VERSION=$( curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" |
grep '"tag_name":' |
sed -E 's/."v([^"]+)"./\1/'
) && curl -L -o dockle.tar.gz https://github.com/goodwithtech/dockle/releases/download/v${VERSION}/dockle_${VERSION}_Linux-64bit.tar.gz &&
tar zxvf dockle.tar.gz - ./dockle --exit-code 1 dockle-ci-test:${CI_COMMIT_SHORT_SHA}

root@kitploit:~
</details>

- 例: https://gitlab.com/tomoyamachi/dockle-ci-test/-/jobs/238215077
- リポジトリ: https://github.com/goodwithtech/dockle-ci-test

## プライベートDockerレジストリの認証

`Dockle`は、`Docker`やその他のサードパーティツールをインストールしなくても、プライベートレジストリからイメージをダウンロードできます。CIプロセスで使いやすいように設計されています。

必要なのは、`Dockle`をインストールして環境変数を設定することだけです。

- 注: ローカルマシンでENV変数を使用することはお勧めしません。

### Docker Hub

Docker Hubからプライベートリポジトリをダウンロードするには、`DOCKLE_AUTH_URL`、`DOCKLE_USERNAME`、`DOCKLE_PASSWORD`の環境変数を設定する必要があります。```bash
export DOCKLE_AUTH_URL=https://registry.hub.docker.com
export DOCKLE_USERNAME={DOCKERHUB_USERNAME}
export DOCKLE_PASSWORD={DOCKERHUB_PASSWORD}
  • 注意: パブリックリポジトリからダウンロードする場合は、環境変数を設定する必要はありません。

Amazon ECR (Elastic Container Registry)

Dockle は AWS SDK を使用しています。 CLI ツールをインストールする必要はありません。

ツールをダウンロード

チェックポイント概要

  • 各チェックポイントの詳細は CHECKPOINT.md を参照
CODE説明レベル※
CIS の Docker イメージチェックポイント
CIS-DI-0001コンテナ用のユーザーを作成するWARN
CIS-DI-0002信頼できるベースイメージを使用するFATAL
CIS-DI-0003コンテナに不要なパッケージをインストールしないFATAL
CIS-DI-0004イメージをスキャンしてセキュリティパッチを含むように再構築するFATAL
CIS-DI-0005Docker でコンテンツトラストを有効にするINFO
CIS-DI-0006コンテナイメージに HEALTHCHECK 命令を追加するINFO
CIS-DI-0007Dockerfile で update 命令だけを使用しないFATAL
CIS-DI-0008setuid と setgid ファイルの安全性を確認するINFO
CIS-DI-0009Dockerfile で ADD ではなく COPY を使用するFATAL
CIS-DI-0010Dockerfile にシークレットを保存しないFATAL
CIS-DI-0011

レベル

Dockle には5つのチェックレベルがあります。

レベル説明
FATAL実践的かつ慎重であるべき
WARN実践的かつ慎重であるべきだが、使用は限定的(公式イメージでも)
INFOユーティリティやパフォーマンスを低下させる可能性がある
SKIP対象ファイルが見つからない
PASS問題が見つからない

一般的な例

イメージのスキャン

イメージ名(とタグ)を指定するだけです。```bash $ dockle goodwithtech/test-image:v1

root@kitploit:~
<details>
<summary>結果</summary>```
FATAL   - CIS-DI-0001: Create a user for the container
        * Last user should not be root
WARN    - CIS-DI-0005: Enable Content trust for Docker
        * export DOCKER_CONTENT_TRUST=1 before docker pull/build
FATAL   - CIS-DI-0006: Add HEALTHCHECK instruction to the container image
        * not found HEALTHCHECK statement
FATAL   - CIS-DI-0007: Do not use update instructions alone in the Dockerfile
        * Use 'Always combine RUN 'apt-get update' with 'apt-get install' : /bin/sh -c apt-get update && apt-get install -y git
FATAL   - CIS-DI-0008: Remove setuid and setgid permissions in the images
        * Found setuid file: etc/passwd grw-r--r--
        * Found setuid file: usr/lib/openssh/ssh-keysign urwxr-xr-x
        * Found setuid file: app/hoge.txt ugrw-r--r--
        * Found setuid file: app/hoge.txt ugrw-r--r--
        * Found setuid file: etc/shadow urw-r-----
FATAL   - CIS-DI-0009: Use COPY instead of ADD in Dockerfile
        * Use COPY : /bin/sh -c #(nop) ADD file:81c0a803075715d1a6b4f75a29f8a01b21cc170cfc1bff6702317d1be2fe71a3 in /app/credentials.json
FATAL   - CIS-DI-0010: Do not store secrets in ENVIRONMENT variables
        * Suspicious ENV key found : MYSQL_PASSWD
FATAL   - CIS-DI-0010: Do not store secret files
        * Suspicious filename found : app/credentials.json
PASS    - DKL-DI-0001: Avoid sudo command
FATAL   - DKL-DI-0002: Avoid sensitive directory mounting
        * Avoid mounting sensitive dirs : /usr
PASS    - DKL-DI-0003: Avoid apt-get/apk/dist-upgrade
PASS    - DKL-DI-0004: Use apk add with --no-cache
FATAL   - DKL-DI-0005: Clear apt-get caches
        * Use 'apt-get clean && rm -rf /var/lib/apt/lists/*' : /bin/sh -c apt-get update && apt-get install -y git
PASS    - DKL-DI-0006: Avoid latest tag
FATAL   - DKL-LI-0001: Avoid empty password
        * No password user found! username : nopasswd
PASS    - DKL-LI-0002: Be unique UID
PASS    - DKL-LI-0002: Be unique GROUP
aws

AWS CLIの環境変数 を使用してください。```bash export AWS_ACCESS_KEY_ID={AWS ACCESS KEY} export AWS_SECRET_ACCESS_KEY={SECRET KEY} export AWS_DEFAULT_REGION={AWS REGION}

root@kitploit:~
### GCR (Google Container Registry)

`Dockle` は Google Cloud SDK を使用します。そのため、`gcloud` コマンドをインストールする必要はありません。

対象プロジェクトのリポジトリを使用したい場合は、`GOOGLE_APPLICATION_CREDENTIAL` を介して設定できます。```bash
# must set DOCKLE_USERNAME empty char
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credential.json

自己ホスト型レジストリ (BasicAuth)

BasicAuthサーバーは DOCKLE_USERNAME と DOCKLE_PASSWORD が必要です。```bash export DOCKLE_USERNAME={USERNAME} export DOCKLE_PASSWORD={PASSWORD}

if you'd like to use 80 port, use NonSSL

export DOCKLE_NON_SSL=true

root@kitploit:~
## 貢献者

### コード貢献者

このプロジェクトは、貢献してくださるすべての方々のおかげで成り立っています。[[貢献する](https://github.com/goodwithtech/dockle/blob/HEAD/CONTRIBUTING.md)]。
<a href="https://github.com/goodwithtech/dockle/graphs/contributors"><img src="https://opencollective.com/dockle/contributors.svg?width=890&amp;button=false" /></a>

### 資金貢献者

資金貢献者になり、コミュニティを維持する手助けをしてください。[[貢献する](https://opencollective.com/dockle/contribute)]

#### 個人

<a href="https://opencollective.com/dockle"><img src="https://opencollective.com/dockle/individuals.svg?width=890"></a>

#### 組織

あなたの組織でこのプロジェクトを支援してください。あなたのロゴがウェブサイトへのリンクとともにここに表示されます。[[貢献する](https://opencollective.com/dockle/contribute)]

<a href="https://www.tines.com/?utm_source=oss&utm_medium=sponsorship&utm_campaign=dockle"><img src="https://assets.kitploit.com/production/public/readmes/4137/e063c5948228b346da42565b27ee62f2dd85648c0de86a2b184c7f111319d275.png"></a>
<a href="https://opencollective.com/dockle/organization/1/website"><img src="https://opencollective.com/dockle/organization/1/avatar.svg"></a>
<a href="https://opencollective.com/dockle/organization/2/website"><img src="https://opencollective.com/dockle/organization/2/avatar.svg"></a>
<a href="https://opencollective.com/dockle/organization/3/website"><img src="https://opencollective.com/dockle/organization/3/avatar.svg"></a>
<a href="https://opencollective.com/dockle/organization/4/website"><img src="https://opencollective.com/dockle/organization/4/avatar.svg"></a>
<a href="https://opencollective.com/dockle/organization/5/website"><img src="https://opencollective.com/dockle/organization/5/avatar.svg"></a>
<a href="https://opencollective.com/dockle/organization/6/website"><img src="https://opencollective.com/dockle/organization/6/avatar.svg"></a>
<a href="https://opencollective.com/dockle/organization/7/website"><img src="https://opencollective.com/dockle/organization/7/avatar.svg"></a>
<a href="https://opencollective.com/dockle/organization/8/website"><img src="https://opencollective.com/dockle/organization/8/avatar.svg"></a>
<a href="https://opencollective.com/dockle/organization/9/website"><img src="https://opencollective.com/dockle/organization/9/avatar.svg"></a>

### OSSプログラムサポーター

このプロジェクトは、以下のOSSプログラムを通じて提供されるサービスを利用しています。

<a href="https://flatt.tech/oss/gmo/trampoline" target="_blank"><img src="https://flatt.tech/assets/images/badges/gmo-oss.svg" height="24px"/></a>
<a href="https://github.com/1Password/for-open-source" target="_blank"><img src="https://img.shields.io/badge/1Password-OSS%20Program-0094F5?logo=1password&amp;logoColor=white" height="24px"/></a>

# ライセンス

- Apache License 2.0

# 作者

[@tomoyamachi](https://github.com/tomoyamachi) (Tomoya Amachi)

特別な感謝を [@knqyf263](https://github.com/knqyf263) (Teppei Fukuda) と [Trivy](https://github.com/knqyf263/trivy) に捧げます
検証済みパッケージのみをインストールする
INFO
Docker 用 Dockle チェックポイント
DKL-DI-0001sudo コマンドを避けるFATAL
DKL-DI-0002機密ディレクトリのマウントを避けるFATAL
DKL-DI-0003apt-get dist-upgrade を避けるWARN
DKL-DI-0004apk add は --no-cache と共に使用するFATAL
DKL-DI-0005apt-get のキャッシュをクリアするFATAL
DKL-DI-0006latest タグを避けるWARN
Linux 用 Dockle チェックポイント
DKL-LI-0001空のパスワードを避けるFATAL
DKL-LI-0002UID/GROUP をユニークにするFATAL
DKL-LI-0003必要なファイルのみ配置するINFO