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
More from this author
+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 haTop issues
#556Execute benchmark on rootless docker32 comments · 2024-09-04#405v1.3.5 needs to be signed, tagged and published.24 comments · 2019-11-06#480Docker-bench-security check 2.2 icc issue16 comments · 2021-08-04#482Exit Code Control, and Output Format Options13 comments · 2021-09-19#446Running docker-bench-security under WSL17 comments · 2020-10-13#355Version 3 restart policy7 comments · 2019-01-23#261Doesn't run with Windows hosts.7 comments · 2017-10-02#565Support for Docker rootless5 comments · 2025-01-24
Latest release
v1.6.1 v1.6.1 2023-12-20What'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