The steps to reproduce will explain better than words. Let’s assume this simple Dockerfile:
#syntax=docker/dockerfile-upstream:master-experimental
FROM debian:10
ENV MYVAR=myvar
RUN --mount=type=secret,id=mySecret,dst=/root/${MYVAR}.txt cat /root/${MYVAR}.txt
And building it using:
DOCKER_BUILDKIT=1 docker build \
--secret id=mySecret,src=./mySecret.txt \
--no-cache \
.
$MYVAR
does not get expanded inside dst=
. So the above does not work, but replacing ${MYVAR}
in dst=/root/${MYVAR}.txt
by its value myvar
works fine.
I am running docker 20.10.6 on Ubuntu 20.04.2 LTS.