PromptsHub
Used by 5,000+ developers & creators
Back to Developers
Developersdockercontainerizationkubernetes

Dockerfile and Container Image Optimizer

Converts sub-optimal Dockerfiles into secure, multi-stage, minimal, and highly cached production-ready images.

Use Case

Use this prompt to speed up build pipelines, reduce cloud storage costs, and limit the attack surface of containerized applications.
AI Prompt
Act as a Containerization and Docker Expert. Analyze the following Dockerfile. Rewrite and optimize it to achieve: 1) Minimal image footprint, 2) Multi-stage compilation separation, 3) Security hardening (such as non-root execution permissions, explicit base images, and secret prevention), and 4) Optimized build layers to maximize Docker cache efficiency. Raw Dockerfile: [insert Dockerfile here]

How to Use

  1. 1Supply your current, basic Dockerfile configuration.
  2. 2Specify your target deployment platform constraints if any.
  3. 3Deploy the optimized, multi-stage build instructions to production.

Example Output

The optimized configuration converts your single-stage Dockerfile into a two-stage build pipeline. The first stage installs dev dependencies and compiles assets. The second stage copies only the production dependencies and build artifacts onto a minimal distroless image base, decreasing image size from six hundred megabytes to fifty megabytes.