sudo ./docker-bench-security.shExecutes the full CIS Docker Benchmark audit script against the local host using default settings.
A script that checks a Docker host against dozens of CIS Docker Benchmark best practices for production deployments.
git clone https://github.com/docker/docker-bench-security.git && cd docker-bench-security && sudo sh docker-bench-security.shsudo ./docker-bench-security.shExecutes the full CIS Docker Benchmark audit script against the local host using default settings.
docker run --rm --net host --pid host --userns host --cap-add audit_control -v /etc:/etc:ro -v /var/lib:/var/lib:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --label docker_bench_security docker/docker-bench-securityRuns Docker Bench for Security from a container with necessary volume mounts and privileges to audit the host.
sudo ./docker-bench-security.sh -hDisplays the help menu listing all available flags and execution options.
sudo ./docker-bench-security.sh -l <filename>Runs the benchmark and saves the output to a specified log file in the current directory.
Example
sudo ./docker-bench-security.sh -l my-audit-logsudo ./docker-bench-security.sh -pPrevents the script from writing any log files to disk, outputting only to stdout.
sudo ./docker-bench-security.sh -jOutputs the audit results in JSON format to the console for parsing.
sudo ./docker-bench-security.sh -j -l output.jsonRuns the benchmark and saves the results in JSON format to a specific file.
sudo ./docker-bench-security.sh -c host_configurationLimits the audit strictly to Section 1: Host Configuration checks.
sudo ./docker-bench-security.sh -c docker_daemon_configurationLimits the audit strictly to Section 2: Docker Daemon Configuration checks.
sudo ./docker-bench-security.sh -c docker_daemon_configuration_filesLimits the audit strictly to Section 3: Docker Daemon Configuration Files checks.
sudo ./docker-bench-security.sh -c container_imagesLimits the audit strictly to Section 4: Container Images and Build File checks.
sudo ./docker-bench-security.sh -c container_runtimeLimits the audit strictly to Section 5: Container Runtime checks.
sudo ./docker-bench-security.sh -c docker_security_operationsLimits the audit strictly to Section 6: Docker Security Operations checks.
sudo ./docker-bench-security.sh -c docker_swarm_configurationLimits the audit strictly to Section 7: Docker Swarm Configuration checks.
sudo ./docker-bench-security.sh -e check_2.6Runs the full benchmark but explicitly excludes check 2.6 (TLS authentication).
sudo ./docker-bench-security.sh -e check_4.5,check_5.1Runs the full benchmark while excluding multiple specific checks defined by a comma-separated list.
sudo ./docker-bench-security.sh -e docker_swarm_configurationRuns the full benchmark but skips the entire Docker Swarm Configuration section.
sudo ./docker-bench-security.sh -t <image_tag>Limits the container image checks to only images matching the specified tag.
Example
sudo ./docker-bench-security.sh -t postgresdocker run --rm --net host --pid host --userns host --cap-add audit_control -v /etc:/etc:ro -v /var/lib:/var/lib:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --label docker_bench_security docker/docker-bench-security -c host_configurationRuns only the host configuration checks using the containerized version of the tool.
docker run --rm --net host --pid host --userns host --cap-add audit_control -v /etc:/etc:ro -v /var/lib:/var/lib:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --label docker_bench_security docker/docker-bench-security -e check_1.1Runs the containerized benchmark excluding specific kernel capability checks.
sudo ./docker-bench-security.sh -c host_configuration,container_runtime -e check_1.2Combines inclusion and exclusion flags to audit host and runtime sections but skip disk partition checks.
sudo ./docker-bench-security.sh -c check_4.1 -t production_imageChecks user creation within containers only for images tagged 'production_image'.
sudo ./docker-bench-security.sh -c check_5.10Verifies that memory usage limits are set for containers to prevent DoS attacks.
sudo ./docker-bench-security.sh -c check_5.11Verifies that CPU priority is set appropriately for containers.
sudo ./docker-bench-security.sh -c check_5.12Ensures the container's root filesystem is mounted as read-only.
sudo ./docker-bench-security.sh -c check_5.31Checks that the docker socket is not mounted inside any container.
sudo ./docker-bench-security.sh -l /var/log/audit/docker_compliance_$(date +%F).logGenerates a timestamped compliance log file in a dedicated audit directory.
docker run --rm --net host --pid host --userns host --cap-add audit_control -v /etc:/etc:ro -v /var/lib:/var/lib:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --label docker_bench_security docker/docker-bench-security -j > report.jsonRuns the containerized audit in a pipeline and saves JSON output to the host.
sudo ./docker-bench-security.sh -b -l custom.log -c container_images -e check_4.6Runs a customized audit on images, logging to a file, excluding health check validation.
sudo ./docker-bench-security.sh -c 1,2,3Runs checks for sections 1, 2, and 3 using the older comma-separated integer syntax.
docker-bench-security.shAttempts to run the script without sudo, useful for verifying rootless docker configurations.
rm docker-bench-security.log.jsonRemoves the default JSON log file generated by the tool after audit completion.
The Docker CLI: build, run and inspect containers and images, and audit their configuration, mounts, capabilities and networks.
Checks whether a Kubernetes cluster is deployed securely by running the CIS Kubernetes Benchmark tests against nodes and control plane.
Aqua’s all-in-one scanner for vulnerabilities, misconfigurations, secrets and licenses in container images, filesystems, repositories, IaC and Kubernetes.