Docker Optimization
When to Use This Skill
Use when changing Dockerfile/compose, or when improving image efficiency and reliability.
Optimization Workflow
- •Keep multi-stage build boundaries clear (build/test vs runtime).
- •Minimize runtime image contents and attack surface.
- •Improve layer caching strategy (copy package manifests before sources where applicable).
- •Validate healthcheck/startup behavior and exposed ports.
- •Validate compose configuration and containerized test flows.
- •Update root
README.mdif Docker workflows changed.
Optimization Rules
- •Prefer small trusted base images and regular rebuild cadence.
- •Keep
.dockerignoretight to reduce context size. - •Avoid unnecessary packages/tools in production image.
- •Run application as non-root where possible.