This order is important for rebuilding and you typically will want to put your RUN commands before your COPY commands.
For example, in an instance where you wanted to copy multiply.py into the container image instead of sum.py. If the COPY line came before the RUN line, it would need to rebuild the whole image. If the COPY line came second then it would use the cached RUN layer from the previous build and then only rebuild the COPY layer.
In the example that introduces the ENTRYPOINT command, we currently have:
RUN apk add --update python3 py3-pip python3-dev
COPY sum.py /home
This PR fixes the order as per the recommendation earlier in this lesson by interchanging these two lines.
In the section titled The Importance of Command Order in a Dockerfile, the text states that:
In the example that introduces the
ENTRYPOINT
command, we currently have:This PR fixes the order as per the recommendation earlier in this lesson by interchanging these two lines.