Apply Docker security best practices

Apache 2.0

Apply security-focused Docker best practices to Dockerfiles. This includes running as a non-root user (CIS 4.1) and using COPY instead of ADD where appropriate (CIS 4.9).

org.openrewrite.docker.DockerSecurityBestPractices
mod run . --recipe=org.openrewrite.docker.DockerSecurityBestPractices

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Add USER instruction appuser
  2. Replace ADD with COPY
  3. Find containers running as root
  4. Find unpinned base images
  5. Find end-of-life Docker base images
  6. Find missing HEALTHCHECK