docker build_error ai_generated true

Sending build context to Docker daemon: extremely slow / OOM

ID: docker/context-too-large

Also available as: JSON · Markdown
90%Fix Rate
92%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
27 active

Root Cause

Docker build context includes unnecessary files (node_modules, .git, data).

generic

Workarounds

  1. 95% success Add .dockerignore with node_modules, .git, and data dirs
    echo 'node_modules\n.git\n*.log' > .dockerignore

    Sources: https://docs.docker.com/build/building/context/#dockerignore-files

  2. 88% success Use multi-stage builds to only copy needed files
    Use multi-stage builds to only copy needed files

    Sources: https://docs.docker.com/build/building/multi-stage/

Dead Ends

Common approaches that don't work:

  1. Increase Docker daemon memory 65% fail

    Doesn't fix the root cause, still slow

  2. Move Dockerfile to empty directory 70% fail

    Breaks COPY commands, loses project context

Error Chain

Frequently confused with: