I'm trying to understand for what type of commands the docker cache is dangerous.
Here a few examples and what I believe will happen.
In my head this will always use the cache. Do I care?
Not really because if the previous cached installed version of curl made my image work, it should still be working:
RUN apt-get update && apt-get install --no-install-recommends -yy curl
This COPY command will use the cache only if requirements.txt is the same as before:
COPY ./requirements.txt /opt/client_web/requirements.txt
This RUN command will cache only if the content of /opt/client_web/requirements.txt is exactly the same as before otherwise it will not use the cache:
RUN python3 -m pip install --default-timeout=100 -r /opt/client_web/requirements.txt
This RUN command will probably always cache and it is ok. Of course I won't get a newer version of pip if it gets released:
RUN curl https://bootstrap.pypa.io/get-pip.py > get-pip.py && python3 get-pip.py
Are the above statements correct?
If yes, can we say that the docker cache is used only if the command doesn't involve changed of files?