docker /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.

★ 9,714⑂ 1,030👁 231⑃ 362● 213▤ 11
ShellApache-2.0Created 2015-05-11
More from this author
Download: v1.6.1v1.6.1 ↓1.6.12023-12-20
+1
Daily
9,714
stars
1,030
forks
231
watchers
362
prs
213
issues
11
releases

README

Docker Bench for Security

!Docker Bench for Security running

The Docker Bench for Security is a script that checks for dozens of common best-practices around deploying Docker containers in production. The tests are all automated, and are based on the CIS Docker Benchmark v1.6.0.

We are making this available as an open-source utility so the Docker community can have an easy way to self-assess their hosts and Docker containers against this benchmark.

Release | CIS |
:---:|:---:|
1.6.0|1.6.0|
1.5.0|1.5.0|
1.3.6|1.4.0|
1.3.5|1.2.0|
1.3.3|1.1.0|
1.3.0|1.13.0|

 Running Docker Bench for Security

 Run from your base host

You can simply run this script from your base host by running:

sh
git clone https://github.com/docker/docker-bench-security.git
cd docker-bench-security
sudo sh docker-bench-security.sh


 Note: jq is an optional but recommended dependency.

 Run with Docker

 Building Docker image

You have two options if you wish to build and run this container yourself:

1. Use Docker Build:

sh
git clone https://github.com/docker/docker-bench-security.git
cd docker-bench-security
docker build --no-cache -t docker-bench-security .


Followed by an appropriate docker run command as stated below.

2. Use Docker Compose:

sh
git clone https://github.com/docker/docker-bench-security.git
cd docker-bench-security
docker-compose run --rm docker-bench-security


_Please note that the docker/docker-bench-security image is out-of-date and and a manual build is required. See 405 for more information._

Note that this container is being run with a lot of privilege -- sharing the host's filesystem, pid and network namespaces, due to portions of the benchmark applying to the running host.

 Using the container

sh
docker run --rm --net host --pid host --userns host --cap-add audit_control \
    -e DOCKER_CONTENT_TRUST=$DOCKER_CONTENT_TRUST \
    -v /etc:/etc:ro \
    -v /usr/bin/containerd:/usr/bin/containerd:ro \
    -v /usr/bin/runc:/usr/bin/runc:ro \
    -v /usr/lib/systemd:/usr/lib/systemd:ro \
    -v /var/lib:/var/lib:ro \
    -v /var/run/docker.sock:/var/run/docker.sock:ro \
    --label docker_bench_security \
    docker-bench-security


Don't forget to adjust the shared volumes according to your operating system.
Some examples are:

1. On Ubuntu the docker.service and docker.secret files are located in
   /lib/systemd/system folder by default.

sh
docker run --rm --net host --pid host --userns host --cap-add audit_control \
    -e DOCKER_CONTENT_TRUST=$DOCKER_CONTENT_TRUST \
    -v /etc:/etc:ro \
    -v /lib/systemd/system:/lib/systemd/system:ro \
    -v /usr/bin/containerd:/usr/bin/containerd:ro \
    -v /usr/bin/runc:/usr/bin/runc:ro \
    -v /usr/lib/systemd:/usr/lib/systemd:ro \
    -v /var/lib:/var/lib:ro \
    -v /var/run/docker.sock:/var/run/docker.sock:ro \
    --label docker_bench_security \
    docker-bench-security


2. The /etc/hostname file is missing on macOS, so it will need to be created first. Also, Docker Desktop on macOS doesn't ha

Top issues

Latest release

v1.6.1 v1.6.1 2023-12-20
What's Changed
 "above" - "below" by @ismailarilik in https://github.com/docker/docker-bench-security/pull/540
 handle "null" values and missing jq by @halfluke in https://github.com/docker/docker-bench-security/pull/541
 feat: use SHA instead of tags for base image by @UlisesGascon in https://github.com/docker/docker-bench-security/pull/543
 update check ID and add check groups for CIS Controls v8 by @martipoe in https://github.com/docker/docker-bench-security/pull/546

 New Contributors
 @ismailarilik made their first contribution in https://github.com/docker/docker-bench-security/pul

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON