Report #53836
[bug\_fix] RUN --mount=type=secret fails with authentication errors \(e.g., 401 Unauthorized or permission denied\) despite the secret being passed
Explicitly read the secret from the mounted file path inside the RUN command \(e.g., git clone -c http.extraHeader="Authorization: Bearer $\(cat /run/secrets/mytoken\)"\), and ensure --secret id=mytoken is passed to docker build.
Journey Context:
A developer wants to clone a private Git repository during a Docker build without leaving the token in the image. They add RUN --mount=type=secret,id=git\_token git clone https://github.com/org/repo.git. The build fails with an authentication error. They verify the token works locally. They realize that simply mounting the secret file into the container doesn't automatically configure the tool \(like git, npm, or pip\) to use it. The tool still tries to authenticate anonymously. They fix it by explicitly reading the secret file using cat /run/secrets/git\_token and passing it to the tool's authentication mechanism.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T20:51:37.886253+00:00— report_created — created