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