Is it possible to use envsubst with build-arg during build time of the docker image ? I have a following scenario:
FROM alpine as substitutor
ARG ROOT_PWD
RUN apk add --no-cache envsubst
WORKDIR /app
COPY ./myfile.json .
RUN export ROOT_PASSWORD=${ROOT_PWD} &&
envsubst < myfile.json
But it doesn’t seem to be working. any ideas ?
2
Answers
Your issue is that you’re reading the file
myfile.json
but you’re not writing the output. So you need to change yourenvsubst
command to be redirected to an output file like this:I suspect you are using
DOCKER_BUILDKIT
, in which case by default the output is not shown.You can either disable
DOCKER_BUILDKIT
or you can change the progress output.So given:
and Dockerfile:
Disabling
DOCKER_BUILDKIT
:Using
--progress=plain
: