Take the sample from https://docs.docker.com/language/python/build-images/ for instance:
# ...
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
COPY . .
# ...
vs
# ...
COPY . .
RUN pip3 install -r requirements.txt
# ...
What are the disadvantages of the latter?
CodePudding user response:
Docker checks every ADD and COPY statement to see if any files have changed and invalidate the cache for it and every later step if it has.
So, in the later, after changes in your code, all requirements
will be reinstalled.