Docker Build Failure Diagnosis Prompt
Diagnose a failing `docker build` from the error output and Dockerfile, pinpoint the breaking instruction (cache, COPY path, network, platform, dependency), and give a tested fix.
- Target user
- Developers and DevOps engineers
- Difficulty
- Beginner
- Tools
- Claude, ChatGPT
The prompt
You are a senior build engineer who diagnoses broken `docker build` runs quickly and precisely. I will provide: - The full build error output (the BuildKit log, including the failing step number) - My Dockerfile - The build command and context I ran (flags, build args, where I ran it from) - Whether it builds locally but fails in CI, or vice versa Your job: 1. **Locate the failing step** — quote the exact instruction and line that failed, and translate the error into plain language. 2. **Classify the failure** — bucket it: COPY/ADD path or context mismatch, missing build arg/env, package/dependency resolution, network/proxy, permission, platform/arch mismatch, syntax, or a busted cache. 3. **Explain the why** — tie the error to the cause (e.g. file outside build context, `.dockerignore` excluding a needed file, apt/npm registry unreachable, lockfile drift, wrong `--platform`). 4. **Give the fix** — the exact Dockerfile edit, build-context change, build arg, or flag; show the corrected line. 5. **Address local-vs-CI gaps** — if it only fails in one place, compare context, cache state, network egress, and base-image pinning between the two. 6. **Re-run guidance** — provide the command to rebuild with `--no-cache` or `--progress=plain` to confirm, and a faster cached re-run once green. Output as: (a) the failing instruction, (b) failure class, (c) root cause, (d) corrected Dockerfile/command, (e) verification build command. If the log is truncated past the error, tell me to re-run with `--progress=plain` and paste the full step output.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Multi-Arch Image Build with Buildx Design Prompt
Design a buildx multi-arch (amd64/arm64) image pipeline with the right builder, cross-compilation strategy, cache export, and a single multi-platform manifest pushed to a registry.
-
Multi-Stage Dockerfile Size & Build-Cache Optimization Prompt
Refactor a bloated Dockerfile into a lean multi-stage build that maximizes layer cache hits, shrinks the final image, and speeds up CI rebuilds without breaking the runtime.
-
Docker Build Context Reduction & .dockerignore Audit Prompt
Audit a bloated Docker build context, identify what is being uploaded to the daemon unnecessarily, and produce a tuned .dockerignore plus COPY strategy that shrinks context and speeds builds.
-
BuildKit Cache Mount Strategy Design Prompt
Design a BuildKit cache-mount and cache-export strategy that speeds up dependency installs and compilation across local and CI builds without shipping cache into the final image.
More Docker with AI prompts & error guides
Browse every Docker with AI prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.