Ask Your Question
2

What is the method to duplicate variables from one stage to another in a multi-stage Docker build?

asked 2021-08-13 11:00:00 +0000

devzero gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-01-11 13:00:00 +0000

nofretete gravatar image

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
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-08-13 11:00:00 +0000

Seen: 11 times

Last updated: Jan 11 '22