This tutorial shows software testers some simple examples for Docker audit. Here now we will make some audits on Docker environment and Dockerfiles.
Docker environment audit
# check Docker environment with docker-bench-security $ docker run -it --net host --pid host --cap-add audit_control \ -v /var/lib:/var/lib \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /usr/lib/systemd:/usr/lib/systemd \ -v /etc :/etc --label docker_bench_security \ docker/docker-bench-security
Note: 1st the space after /etc is only because of security settings from my provider! 2nd create os specific docker-bench-security (example CentOS)
Dockerfile audit
# install on RedHat, CentOS, Fedora ... $ yum install epel-release && yum install lynis # install on Debian, Ubuntu ... $ apt-get install lynis # Suse $ zypper install lynis # install via Homebrew $ brew install lynis # audit Dockerfile $ lynis audit dockerfile Dockerfile # check log file $ cat /var/log/lynis.log $ cat /var/log/lynis-report.dat
Lint Dockerfile with Haskell Dockerfile Linter
# simply run Container again Dockerfile $ docker run --rm -i lukasmartinelli/hadolint < Dockerfile