Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The method to duplicate variables from one stage to another in a multi-stage Docker build is to use the --from flag and reference the previous stage's image name or index to copy the needed environment variables. For example:

FROM stage1 AS build
# build stage

FROM stage2
ENV VARIABLE_NAME=value
COPY --from=build /path/to/file /destination/path
# copy file from previous stage and use the environment variable in this stage