Skip to main content

Claude/ChatGPT Prompt to Cut a Docker Image from 1GB to 100MB

Audit a bloated Docker image and methodically slim it with multi-stage builds, distroless/alpine, pruned deps, and a new Dockerfile.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt makes the AI a senior DevOps engineer that returns a working slimmer Dockerfile and a real reduction plan, not a list of tips. You provide the [app_language], the [current_size], the [target_size], and your [dockerfile]. It audits where the bloat comes from (base image, build tools, dev dependencies, caches), introduces a multi-stage build that ships only the runtime artifact, swaps to a distroless or alpine base justified for your language, prunes dev dependencies and removes compilers from the final stage, adds a .dockerignore and squashes layers where it helps, and states the estimated final size and the single biggest contributor to the reduction.

The structure works because it diagnoses the bloat before rewriting, so the changes target real weight rather than guesswork that may not move the needle. [app_language] justifies the base-image choice; what is safe to strip for one runtime differs for another. [current_size] and [target_size] frame the goal and let the model say whether the target is realistic for your runtime or wishful. Pasting your actual [dockerfile] is what lets the audit name specific lines and layers rather than speak in generalities. The fastest win is usually the multi-stage split that leaves the compiler and dev dependencies behind in the build stage, not merely picking the slimmest base image.

When to use it

  • A bloated image slows every pull, autoscale event, and cold start.
  • You want a diagnosis of where the size actually comes from, not generic tips.
  • You are preparing an image for production scaling.
  • You want a multi-stage rewrite that ships only the runtime artifact.
  • You need the base-image swap justified for your specific language.
  • You want an estimated final size and the biggest single contributor named.

Example output

You get a bloat audit naming the main contributors (base image, build tools, dev dependencies, caches), the fully rewritten multi-stage Dockerfile, a matching .dockerignore, and a size-reduction breakdown that states the estimated final size and the single biggest contributor to the cut. It is delivered as a working Dockerfile plus the reasoning behind each change, so you can both apply it and understand why the image shrank rather than just receiving a list of generic tips you have to act on yourself.

Pro tips

  • Paste the complete current [dockerfile] so the audit can name specific bloated lines.
  • State [current_size] and [target_size] so the model can judge if the target is realistic.
  • Set [app_language] accurately; it justifies whether distroless or alpine is safe.
  • Expect the multi-stage split to be the biggest win, not the slimmest base image.
  • Confirm the .dockerignore excludes node_modules, build output, and caches.
  • Test the slimmed image end to end; an over-aggressive base can drop a runtime dependency.

Frequently Asked Questions

Is the slimmest base image the main way to cut size?
Usually not. The biggest win is a multi-stage build that leaves the compiler and dev dependencies behind in the build stage, so only the runtime artifact ships. A slimmer base helps, but it is typically a smaller contributor than removing build tooling from the final image.
Will it tell me where the bloat is coming from?
Yes. It audits the base image, build tools, dev dependencies, and caches before rewriting, and the breakdown names the single biggest contributor to the reduction. That diagnosis is what makes the changes target real weight rather than applying generic advice that may not move the needle.
Can it reach my exact target size?
It estimates the final size and frames the work against your `[target_size]`, but the achievable size depends on your language and runtime needs. A heavy runtime may not slim to an arbitrary target, so treat the estimate as informed rather than guaranteed and test the result for missing dependencies.
Why does it pick distroless or alpine for me?
It justifies the base-image swap for your `[app_language]`, since what is safe differs by runtime. Distroless is smallest but lacks a shell, while alpine is easier to debug, so the choice is reasoned for your language rather than applied blindly. Verify the final image still runs correctly.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Docker & Kubernetes Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support