Dockerfile Doctor
Faster builds, smaller images, fewer headaches
Paste your Dockerfile and get it back cleaner, smaller, and easier to cache. Good starter recipe for developers because the advice is concrete and the output is easy to compare against the original.
INGREDIENTS
PROMPT
Optimize my Dockerfile. Analyze it for: (1) layer ordering — are COPY and RUN commands ordered to maximize cache hits? (2) image size — can I use a smaller base image, multi-stage builds, or remove unnecessary packages? (3) security — am I running as root, exposing unnecessary ports, or including secrets in the image? (4) build speed — what's causing cache invalidation? Return an optimized Dockerfile with a comment above each changed line explaining why. Show estimated before/after image size and build time impact. Dockerfile: [paste your Dockerfile here]
How It Works
Your Claw analyzes your Dockerfile for common inefficiencies: cache-busting
layer order, unnecessary packages, missing .dockerignore entries, running
as root, oversized base images. It returns an optimized version with
explanations for every change.
What You Get
- Layer reordering for optimal cache efficiency
- Multi-stage build conversion to reduce final image size
- Base image recommendations (alpine, distroless, slim variants)
- Security hardening (non-root user, read-only filesystem, minimal packages)
- .dockerignore generation to prevent context bloat
- Rough before/after impact on image size and build speed
Setup Steps
- Paste your Dockerfile
- Optionally share your docker-compose.yml for full context
- Review the optimized version and explanations
- Build and compare
Tips
- COPY package*.json before COPY . is the #1 quick win for Node.js projects
- Multi-stage builds can cut image size by 80%+
- Ask about debugging strategies for minimal production images
- The Claw can generate a docker-compose.yml from scratch if you describe your stack
- Also handles docker-compose optimization (networking, volume mounts, env management)