Docker & Containers implementation checklist
This checklist provides actionable verification steps for securing, optimizing, and deploying Docker containers to production environments. It focuses on reducing attack surfaces, ensuring resource availability, and maintaining operational visibility.
Image Hardening and Optimization
0/5Implement Non-Root User
criticalVerify the Dockerfile includes a 'USER' instruction with a specific UID/GID to prevent the container from running as root.
Pin Base Image Versions
criticalReplace 'latest' tags with specific version numbers or SHA256 digests to ensure build reproducibility and prevent breaking changes.
Utilize Multi-Stage Builds
recommendedSeparate the build environment from the runtime environment to ensure the production image contains only the compiled binary and necessary dependencies.
Clean Package Manager Caches
recommendedEnsure 'apt-get clean' or equivalent commands are executed within the same 'RUN' layer as package installation to minimize image size.
Scan for Vulnerabilities
criticalRun an automated scan using Trivy or Docker Scout and verify that no 'Critical' or 'High' severity CVEs exist in the final image.
Resource Management
0/5Define Memory Limits
criticalSet hard memory limits (e.g., 'mem_limit' in Compose) to prevent a single container from causing host-wide Out-Of-Memory (OOM) events.
Set CPU Reservations
criticalConfigure CPU limits or shares to ensure the host scheduler provides enough cycles for critical system processes and other containers.
Configure Restart Policies
criticalSet the restart policy to 'unless-stopped' or 'on-failure' to ensure service availability after crashes or host reboots.
Enable Log Rotation
criticalConfigure the 'json-file' or 'journald' log driver with 'max-size' and 'max-file' options to prevent disk exhaustion from container logs.
Set Ulimits
recommendedAdjust 'nofile' and 'nproc' ulimits in the container configuration to handle the expected number of concurrent connections or processes.
Networking and Security
0/5Use Custom Bridge Networks
criticalVerify that containers are attached to user-defined bridge networks rather than the default bridge to enable automatic DNS resolution and isolation.
Restrict Port Exposure
criticalAudit the 'EXPOSE' instruction and '-p' flags to ensure only the minimum required ports are accessible to the host or external network.
Apply Read-Only Root Filesystem
recommendedRun the container with the '--read-only' flag and use temporary volumes for directories requiring write access (e.g., /tmp).
Disable Inter-Container Communication
optionalWhere isolation is required, set '--icc=false' on the Docker daemon or use network aliases to strictly control traffic between services.
Enable No-New-Privileges
recommendedSet the 'no-new-privileges' security option to prevent processes from gaining new privileges via setuid or setgid binaries.
Storage and Persistence
0/5Use Named Volumes for Persistence
criticalEnsure all stateful data is stored in named Docker volumes rather than the container's writable layer to prevent data loss during container recreation.
Avoid Bind Mounts in Production
recommendedReplace host bind mounts with named volumes or specialized drivers to reduce dependency on specific host filesystem paths.
Verify Volume Backup Strategy
criticalTest the restoration process of volume data from snapshots or off-site backups to ensure business continuity.
Clean Up Unused Volumes
optionalImplement a routine 'docker volume prune' or manual audit to reclaim disk space from orphaned volumes.
Set Volume Mount Permissions
recommendedExplicitly set the ':ro' (read-only) flag on volume mounts that the container should not have permission to modify.
Runtime and Observability
0/5Define Healthchecks
criticalInclude a 'HEALTHCHECK' instruction that verifies the application is actually serving requests, not just that the process is running.
Handle SIGTERM Gracefully
criticalVerify the application responds to SIGTERM by closing database connections and finishing active requests within the stop grace period.
Externalize Secrets
criticalConfirm no secrets (API keys, passwords) are stored in environment variables visible to 'docker inspect'; use Docker Secrets or a Vault provider.
Standardize Logging
criticalEnsure the application logs exclusively to stdout and stderr to allow the Docker daemon to capture and forward logs to a central aggregator.
Use .dockerignore
criticalVerify a .dockerignore file exists to prevent sensitive local files (.env, .git, SSH keys) from being copied into the image build context.