I'm new to Docker, sorry if my question sounds dumb. below is a dockerfile from a textbook:
FROM diamol/base AS build-stage RUN echo 'Building...' > /build.txt #line 2 FROM diamol/base AS test-stage COPY --from=build-stage /build.txt /build.txt RUN echo 'Testing...' >> /build.txt #line 6 FROM diamol/base COPY --from=test-stage /build.txt /build.txt CMD cat /build.txt
and the author says:
The RUN instruction executes a command inside a container during the build, and any output from that command is saved in the image layer.
My question is:
Since the author mentioned RUN instruction executes a command inside a container during the build, does it mean that in the first RUN command in line 2, a contianer is created based on the
diamol/base image, and this container modify the content of the files then commit the change back to
diamol/base image, then is container is terminated? and same thing happen in line 6,container created to run and then terminate, image gets updated, is my understanding correct?