docker build ai_generated true

WARNING: One or more build-args were not consumed

ID: docker/build-arg-not-set

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
24 active
27 active

Root Cause

Build arguments passed via --build-arg are not declared in the Dockerfile with ARG.

generic

Workarounds

  1. 96% success Add ARG <name> in the Dockerfile before the RUN command that uses it
    ARG must appear before the first usage in the Dockerfile

    Sources: https://docs.docker.com/reference/dockerfile/#arg

  2. 90% success For multi-stage builds, add ARG in each stage that needs it
    ARG is scoped to the build stage; must be redeclared after each FROM

Dead Ends

Common approaches that don't work:

  1. Ignoring the warning 50% fail

    The build arg isn't being used; the feature it should configure isn't applied

  2. Setting build args as ENV instead 60% fail

    ENV is baked into the image at runtime; different semantics from build-time ARG

Error Chain

Frequently confused with: