Issue with Docker Secrets in Build Step

Hey,

I’m running into an issue with Docker secrets during a multi-stage build. The error occurs at the step where I attempt to mount a secret (GITHUB_TOKEN) and use it in a RUN command to configure Git authentication:

RUN --mount=type=secret,id=GITHUB_TOKEN TOKEN=$(cat /run/secrets/GITHUB_TOKEN) && \
    git config --global url."https://oauth2:${TOKEN}@github.com".insteadOf "https://github.com"

The build fails with the following error:

cat: /run/secrets/GITHUB_TOKEN: No such file or directory
error: failed to solve: process "/bin/sh -c TOKEN=$(cat /run/secrets/GITHUB_TOKEN) && \
git config --global url.\"https://oauth2:${TOKEN}@github.com\".insteadOf \"https://github.com\"" did not complete successfully: exit code: 1

I’m wondering if you support this method (–secret id=GITHUB_TOKEN) for handling secrets during builds, or if using environment variables (e.g., ENV or ARG) is still the only supported approach.

It worked on an older service deployment test but not anymore :smiling_face_with_tear:

Thanks,

Hi @Majdi,

You are right, this is not supported currently and you need to use environment variables.

Ok, no worry, good to know. Thanks :slight_smile: