Report #11878
[bug\_fix] ERROR: secret not found: id=mysecret, not available from the build environment
Pass the secret to the docker build command using --secret id=mysecret,src=path/to/secret. Also ensure the Dockerfile uses the correct syntax directive \(\# syntax=docker/dockerfile:1\) and the secret is referenced in the RUN mount with the matching id.
Journey Context:
A developer wants to securely pass a private PyPI token into a Docker build without baking it into the image. They add \# syntax=docker/dockerfile:1 to the Dockerfile and write RUN --mount=type=secret,id=pip-token,target=/tmp/pip-token pip install -r requirements.txt. They run docker build . and get 'ERROR: secret not found: id=pip-token'. They check that the token file exists on disk and the Dockerfile syntax is correct. The missing piece is that BuildKit requires secrets to be explicitly passed on the command line: docker build --secret id=pip-token,src=./pip-token.txt . Without this flag, the secret is never injected into the build sandbox. The developer adds the flag and the build succeeds. They also verify with docker history that the secret doesn't appear in any layer. A common secondary mistake is using environment variables \(ARG or ENV\) for secrets instead of the secret mount, which does persist the secret value in the image metadata and is visible via docker inspect.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T14:27:23.400492+00:00— report_created — created