Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
openaec-foundation avatar

Docker Errors Build

  • 9 installs
  • 9 repo stars
  • Updated July 8, 2026
  • openaec-foundation/docker-claude-skill-package

Helps with devops & ci/cd tasks.

About

docker-errors-build is a Claude Code skill for devops & ci/cd. It helps solo builders move faster with AI-assisted development.

  • docker-errors-build
  • DevOps & CI/CD
  • AI-coding skill

Docker Errors Build by the numbers

  • 9 all-time installs (skills.sh)
  • +1 installs in the week ending Aug 4, 2026 (Skillselion tracking)
  • Ranked #1,020 of 1,435 DevOps & CI/CD skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/openaec-foundation/docker-claude-skill-package --skill docker-errors-build

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs9
repo stars9
Last updatedJuly 8, 2026
Repositoryopenaec-foundation/docker-claude-skill-package

What it does

Helps with devops & ci/cd tasks.

Files

SKILL.mdMarkdownGitHub ↗

docker-errors-build

Quick Reference

Build Error Debugging Workflow

Build fails
  |
  +-- Read the FULL error message (use --progress=plain for details)
  |
  +-- Identify error category:
  |     |
  |     +-- "file not found" / "checksum" --> COPY/ADD path issue (see 1.1)
  |     +-- "context" / "sending build context" slow --> Context too large (see 1.2)
  |     +-- Rebuilds unexpectedly --> Cache invalidation (see 1.3)
  |     +-- "mount" errors --> BuildKit mount config (see 1.4)
  |     +-- "invalid stage" / "not found" --> Multi-stage reference (see 1.5)
  |     +-- "pull access denied" / "manifest unknown" --> Base image (see 1.6)
  |     +-- "exec format error" --> Platform mismatch (see 1.7)
  |     +-- Variable empty / missing --> ARG scope issue (see 1.8)
  |     +-- "permission denied" --> Build permission (see 1.9)
  |     +-- "parse error" / "unknown instruction" --> Syntax error (see 1.10)
  |
  +-- Apply fix from diagnostic table
  |
  +-- Rebuild with: docker build --progress=plain --no-cache .

Critical Warnings

ALWAYS use --progress=plain when debugging build failures -- the default TTY output hides important error details.

ALWAYS check .dockerignore first when files appear missing during COPY or ADD -- this is the #1 cause of "file not found" errors.

NEVER use --no-cache as a permanent fix for cache problems -- find and fix the root cause of cache invalidation instead.

NEVER put secrets in ARG or ENV instructions -- they persist in image history. ALWAYS use RUN --mount=type=secret.

---

1. Diagnostic Tables

1.1 COPY/ADD File Not Found

Error MessageCauseFix
COPY failed: file not found in build contextFile is outside the build context directoryMove file into the build context or restructure with docker build -f path/Dockerfile context/
COPY failed: file not found in build contextFile is excluded by .dockerignoreRemove or adjust the .dockerignore pattern
failed to compute cache key: failed to calculate checksum of refCOPY source path does not exist relative to build context rootVerify path with ls from the build context directory. Paths are relative to context, NOT Dockerfile location
COPY failed: no source files were specifiedGlob pattern matches zero filesCheck wildcard pattern. Verify files exist: ls <pattern> from context root
ADD failed: file not found in build contextSame causes as COPYSame fixes as COPY. ALWAYS prefer COPY over ADD for local files

Debugging command:

# List what the builder actually sees in the context
docker build --progress=plain -f Dockerfile . 2>&1 | head -5
# Shows: "sending build context to Docker daemon  X.XXkB"

# Check .dockerignore effect
cat .dockerignore

1.2 Build Context Too Large

Error MessageCauseFix
sending build context to Docker daemon takes minutesNo .dockerignore or large files in contextCreate .dockerignore excluding node_modules/, .git/, build artifacts
Context exceeds available memoryExtremely large context (multi-GB)Use .dockerignore. Use --file with a smaller context path. Use multi-stage builds with bind mounts

ALWAYS create a `.dockerignore` file. Without it, the ENTIRE directory tree is sent to the daemon, including node_modules/ (500MB+), .git/ (entire history), and build artifacts.

1.3 Unexpected Cache Invalidation

SymptomCauseFix
npm install reruns on every buildCOPY . . before RUN npm installCopy package.json and lockfile FIRST, install, THEN copy source
apt-get install gets stale packagesapt-get update in a separate RUN layerALWAYS combine: RUN apt-get update && apt-get install -y pkg
Layer rebuilds after unrelated file changeCOPY instruction too broadCopy only the files needed for each step. Order from least to most frequently changed
Cache never hits in CINo cache backend configuredUse --cache-from and --cache-to with registry or GHA backend
RUN layer rebuilds despite identical commandPrevious layer was invalidatedCheck ALL preceding layers -- cache invalidation cascades downward

1.4 BuildKit Mount Errors

Error MessageCauseFix
failed to create LLB definition: rpc error: unknown flag: --mountMissing # syntax=docker/dockerfile:1 directiveAdd # syntax=docker/dockerfile:1 as the FIRST line of the Dockerfile
failed to create LLB definition: rpc error: unknown flag: --mountBuildKit not enabled (pre-Engine 23)Set DOCKER_BUILDKIT=1 or upgrade Docker Engine to 23+
failed to solve: failed to mount cache targetCache directory permissions or path issueVerify target path. Add uid and gid options if running as non-root
error: secret "X" not foundSecret not passed to build commandAdd --secret id=X,src=path to docker build command
could not parse ssh: [default]: stat /nonexistent: no such fileSSH agent not running or key not addedRun eval $(ssh-agent) and ssh-add ~/.ssh/id_rsa before build
inconsistent result from cache mountConcurrent builds with sharing=shared on aptUse sharing=locked for apt cache mounts

1.5 Multi-Stage Reference Errors

Error MessageCauseFix
invalid from flag value X: invalid reference formatStage name contains uppercase or invalid charactersUse lowercase alphanumeric names with hyphens only
failed to solve: X: not found in COPY --from=XStage name does not exist or is misspelledVerify the AS name in the FROM instruction matches exactly
invalid stage index: NNumeric --from=N references a non-existent stageUse named stages (AS build) instead of numeric indexes
circular dependency detectedStage A copies from stage B which copies from ARestructure stages to eliminate circular references

1.6 Base Image Pull Failures

Error MessageCauseFix
pull access denied for X, repository does not existImage name misspelled or does not existVerify image name on Docker Hub or registry. Check for typos
manifest unknown: manifest unknownTag does not exist for this imageVerify tag with docker manifest inspect image:tag
unauthorized: authentication requiredPrivate registry requires loginRun docker login <registry> before building
error pulling image configuration: download failed after attemptsNetwork issue or registry timeoutCheck network connectivity. Retry. Use --pull to force fresh pull
toomanyrequests: You have reached your pull rate limitDocker Hub rate limit exceededAuthenticate with docker login (free accounts get higher limits). Use a registry mirror

1.7 Platform Mismatch

Error MessageCauseFix
exec format errorImage built for wrong CPU architectureAdd --platform linux/amd64 (or target arch) to build command
image with reference X does not match the specified platformPulled image has no manifest for requested platformCheck available platforms: docker manifest inspect image:tag. Build for available platform
no match for platform in manifest listMulti-platform image lacks requested platformUse a different base image that supports your platform

1.8 ARG Scope Issues

SymptomCauseFix
ARG value is empty inside build stageARG declared before FROM but not re-declared afterRe-declare ARG varname (without default) after each FROM that needs it
ARG value not available at runtimeARG is build-time only, not persistedConvert to ENV: ARG VAR then ENV VAR=$VAR if needed at runtime
Variable expansion not working in RUNUsing exec form RUN ["echo", "$VAR"]Exec form does NOT expand variables. Use shell form: RUN echo $VAR
ENV set incorrectly using prior ENV valueSame-line ENV precedenceENV a=bye b=$a uses a's value from BEFORE this line. Split into separate ENV instructions if needed

1.9 Permission Errors During Build

Error MessageCauseFix
permission denied in RUN instructionRunning as non-root USER before installing packagesPlace package installation BEFORE the USER instruction
EACCES: permission denied writing to directoryDirectory owned by root, running as non-rootAdd RUN chown -R user:group /dir BEFORE switching to USER
permission denied on COPY'd scriptScript lacks execute permissionAdd COPY --chmod=755 script.sh /app/ or RUN chmod +x /app/script.sh
open /var/lib/apt/lists/lock: permission deniedRunning apt as non-root userRun apt commands BEFORE USER instruction, or use --mount=type=cache with correct uid/gid

1.10 Dockerfile Syntax Errors

Error MessageCauseFix
failed to solve: dockerfile parse error on line X: unknown instruction: XXXMisspelled instruction or wrong caseInstructions MUST be uppercase: RUN, COPY, FROM, not run, copy, from
failed to solve: dockerfile parse error: missing FROMNo FROM instruction or FROM not firstFROM MUST be the first instruction (after parser directives and ARG)
Unexpected behavior with multi-line RUNMissing \ continuation characterEnd each continued line with \. NEVER leave trailing spaces after \
failed to process "Dockerfile": no parser directive, file is emptyBOM character or wrong encodingSave Dockerfile as UTF-8 without BOM. Remove invisible characters
COPY requires at least two argumentsMissing destination argumentCOPY needs <src> <dest>. Add trailing / for directories: COPY files/ /app/

---

2. Decision Trees

Which Cache Strategy to Use

Problem: Build is slow
  |
  +-- Dependencies reinstall every time?
  |     YES --> Reorder: copy lockfile first, install, then copy source
  |
  +-- Package downloads repeat?
  |     YES --> Add --mount=type=cache for your package manager
  |
  +-- CI builds have no cache?
  |     YES --> Configure --cache-from/--cache-to with registry backend
  |
  +-- Base image pulls every time?
  |     YES --> Pin base image digest. Use --cache-from=type=registry
  |
  +-- Entire Dockerfile rebuilds?
        YES --> Check if early layer changed. Order: system deps > app deps > source

When to Use --no-cache vs --no-cache-filter

Need to force rebuild?
  |
  +-- Entire image from scratch?
  |     --> docker build --no-cache .
  |
  +-- Only specific stage?
  |     --> docker build --no-cache-filter=<stage-name> .
  |
  +-- Fresh base image only?
  |     --> docker build --pull .
  |
  +-- Everything fresh (CI release build)?
        --> docker build --pull --no-cache .

---

3. Essential Debug Commands

# Full build output (ALWAYS use this when debugging)
docker build --progress=plain .

# Build specific stage only
docker build --target <stage-name> .

# Check what the build context contains
tar -czf - -C <context-dir> . | wc -c

# Inspect build cache usage
docker system df
docker builder prune --filter type=regular
docker builder prune -a  # Remove ALL build cache

# Check image layers and sizes
docker history <image>
docker history --no-trunc <image>

# Verify platform of an image
docker inspect --format='{{.Os}}/{{.Architecture}}' <image>

# Check .dockerignore is working
# (compare context size with and without .dockerignore)

---

Reference Links

  • references/diagnostics.md -- Complete error message to cause to solution mapping with exact error strings
  • references/examples.md -- Error reproduction and fix examples with before/after Dockerfiles
  • references/anti-patterns.md -- Build configuration mistakes that cause errors

Official Sources

  • https://docs.docker.com/build/building/best-practices/
  • https://docs.docker.com/build/cache/
  • https://docs.docker.com/build/cache/invalidation/
  • https://docs.docker.com/reference/dockerfile/
  • https://docs.docker.com/build/buildkit/
  • https://docs.docker.com/engine/daemon/troubleshoot/

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.