Quantcast
Channel: Active questions tagged dockerfile - DevOps Stack Exchange
Viewing all articles
Browse latest Browse all 136

why use multiple From instructions in multistage build?

$
0
0

I'm new to Docker, sorry if my question sounds dumb.below is a dockerfile from a textbook shows how multistage build works:

FROM diamol/base AS build-stage                  RUN echo 'Building...'> /build.txt              FROM diamol/base AS test-stageCOPY --from=build-stage /build.txt /build.txtRUN echo 'Testing...'>> /build.txt             FROM diamol/baseCOPY --from=test-stage /build.txt /build.txtCMD cat /build.txt

My questions is:

Why use multiple From instructions? why we don't do sth like:

FROM diamol/base AS build-stage                  RUN echo 'Building...'> /build.txt              COPY --from=build-stage /build.txt /build.txtRUN echo 'Testing...'>> /build.txt             COPY --from=test-stage /build.txt /build.txtCMD cat /build.txt

Viewing all articles
Browse latest Browse all 136

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>