Container Image Linter for Security, Helping build the Best-Practice Docker Image, Easy to start
Container Image Linter for Security, Helping build the Best-Practice Docker Image, Easy to start
Dockle - Container Image Linter for Security, Helping build the Best-Practice Docker Image, Easy to start
Dockle helps you:
$ brew untap goodwithtech/dockle # who use 0.1.16 or older version
$ brew install goodwithtech/r/dockle
$ dockle [YOUR_IMAGE_NAME]See Installation and Common Examples
| Dockle | Hadolint | Docker Bench for Security | Clair | |
|---|---|---|---|---|
| Target | Image | Dockerfile | Host Docker Daemon Image Container Runtime |
Image |
| How to run | Binary | Binary | ShellScript | Binary |
| Dependency | No | No | Some dependencies | No |
| CI Suitable | ✓ | ✓ | x | x |
| Purpose | Security Audit Dockerfile Lint |
Dockerfile Lint | Security Audit Dockerfile Lint |
Scan Vulnerabilities |
You can use Homebrew on Mac OS X or Linux and WSL (Windows Subsystem for Linux).
$ brew install goodwithtech/r/dockleVERSION=$(
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.rpmVERSION=$(
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.debdockle can be installed from the Arch User Repository using dockle or dockle-bin package.
git clone https://aur.archlinux.org/dockle-bin.git
cd dockle-bin
makepkg -sriVERSION=$(
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]if (((Invoke-WebRequest "https://api.github.com/repos/goodwithtech/dockle/releases/latest").Content) -match '"tag_name":"v(?<ver>[^"]+)"') {
$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 }You can get the latest version binary from releases page.
Download the archive file for your operating system/architecture. Unpack the archive, and put the binary somewhere in your $PATH (on UNIX-y systems, /usr/local/bin or the like).
chmod +x dockle)You can install dockle with the asdf version manager with this plugin, which automates the process of installing (and switching between) various versions of github release binaries. With asdf already installed, run these commands to install dockle:
# 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 --versionYou can install dockle with mise, the polyglot tool versions manager. With mise already installed, run these commands to install dockle:
# 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$ 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.goThere's a Dockle image on Docker Hub also. You can try dockle before installing the command.
$ 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]You only need -v /var/run/docker.sock:/var/run/docker.sock when you'd like to scan the image on your host machine.
Simply specify an image name (and a tag).
$ dockle [YOUR_IMAGE_NAME]…Also, you can use Docker to use dockle command as follow.
$ 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]If you'd like to scan the image on your host machine, you need to mount docker.sock.
$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock ...| CODE | DESCRIPTION | LEVEL※ |
|---|---|---|
| CIS's Docker Image Checkpoints | ||
| CIS-DI-0001 | Create a user for the container | WARN |
| CIS-DI-0002 | Use trusted base images for containers | FATAL |
| CIS-DI-0003 | Do not install unnecessary packages in the container | FATAL |
| CIS-DI-0004 | Scan and rebuild the images to include security patches | FATAL |
| CIS-DI-0005 | Enable Content trust for Docker | INFO |
| CIS-DI-0006 | Add HEALTHCHECK instruction to the container image |
INFO |
| CIS-DI-0007 | Do not use update instructions alone in the Dockerfile |
FATAL |
| CIS-DI-0008 | Confirm safety of setuid and setgid files |
INFO |
| CIS-DI-0009 | Use COPY instead of ADD in Dockerfile |
FATAL |
| CIS-DI-0010 | Do not store secrets in Dockerfiles | FATAL |
| CIS-DI-0011 | Install verified packages only | INFO |
| Dockle Checkpoints for Docker | ||
| DKL-DI-0001 | Avoid sudo command |
FATAL |
| DKL-DI-0002 | Avoid sensitive directory mounting | FATAL |
| DKL-DI-0003 | Avoid apt-get dist-upgrade |
WARN |
| DKL-DI-0004 | Use apk add with --no-cache |
FATAL |
| DKL-DI-0005 | Clear apt-get caches |
FATAL |
| DKL-DI-0006 | Avoid latest tag |
WARN |
| Dockle Checkpoints for Linux | ||
| DKL-LI-0001 | Avoid empty password | FATAL |
| DKL-LI-0002 | Be unique UID/GROUPs | FATAL |
| DKL-LI-0003 | Only put necessary files | INFO |
Dockle has 5 check levels.
| LEVEL | DESCRIPTION |
|---|---|
| FATAL | Be practical and prudent |
| WARN | Be practical and prudent, but limited uses (even if official images) |
| INFO | May negatively inhibit the utility or performance |
| SKIP | Not found target files |
| PASS | Not found any problems |
Simply specify an image name (and a tag).
$ dockle goodwithtech/test-image:v1…$ docker save alpine:latest -o alpine.tar
$ dockle --input alpine.tar$ dockle -f json goodwithtech/test-image:v1
$ dockle -f json -o results.json goodwithtech/test-image:v1…$ dockle -f sarif goodwithtech/test-image:v1
$ dockle -f sarif -o results.json goodwithtech/test-image:v1…By default, Dockle exits with code 0 even if there are some problems.
Use the --exit-code, -c option to exit with a non-zero exit code if WARN or FATAL alert were found.
$ dockle --exit-code 1 [IMAGE_NAME]By
No open issues yet, or sync has not completed.