Reputation: 4144
I'm trying to pass an argument to the docker build to have it executed in the Dockerfile as
RUN --mount=type=secret,id=$SECRET_NAME cp /run/secrets/$SECRET_NAME /etc/app/conf
but that will fail during the build time as
> [8/8] RUN --mount=type=secret,id=mysecret cp /run/secrets/mysecret /etc/app/conf:
#13 0.224 cp: cannot stat '/run/secrets/mysecret': No such file or directory
but when I will use it directly in the RUN
command as
RUN --mount=type=secret,id=mysecret cp /run/secrets/mysecret /etc/app/conf
that will work.
Any thoughts?
Upvotes: 0
Views: 324
Reputation: 14723
It seems the feature you suggest ("environment variable expansion of the secret identifier itself") is just not supported by BuildKit, cf. the following two references:
So maybe you could just refactor your Dockerfile so it does not require this feature (which by the way, would have the drawback to hinder legibility/reproducibility, given one could not know the secret identifier just by looking at the sole RUN --mount=…
command).
Upvotes: 1