In a Dockerfile I have a layer which installs requirements.txt
:
FROM python:2.7
RUN pip install -r requirements.txt
When I bui
This is directly mentioned in Docker's own "Best practices for writing Dockerfiles":
If you have multiple Dockerfile steps that use different files from your context, COPY them individually, rather than all at once. This will ensure that each step’s build cache is only invalidated (forcing the step to be re-run) if the specifically required files change.
For example:
COPY requirements.txt /tmp/ RUN pip install --requirement /tmp/requirements.txt COPY . /tmp/
Results in fewer cache invalidations for the RUN step, than if you put the COPY . /tmp/ before it.