Damian's notes – Stop using pip cache in docker images

Damian Kula

Stop using pip cache in docker images

Posted on 2020.08.25

Just a quick tip. Whenever you are using pip inside of your Dockerfile, always use --no-cache-dir argument. In my case, where I was installing a bunch of Python packages inside of the image, I managed to reduce its size from 800MB to less than 550MB.

So remember, always do:

python -m pip install --no-cache-dir -r requirements.txt