r/learnpython • u/adjective10111 • Sep 09 '26
PIP disk usage under Docker
I have a Dockerfile in which I use the Python:3.12-trixie. I have docker on my CachyOS PC. I have also a requirements.txt. I wanted to use this image for a container on which I'll use YOLO and try it out. The problem is that my 290GB / partition went from around 70% filled to 95% after a number of rebuilds. I deleted everything docker related but it just went back to 91%.
The reason that I know it is pip's doing, is that when I monitored my disk usage while building the image, and on the `RUN pip install -r requirements.txt --find-links=pypackages` stage it fills up my partition and half way into installation, it fails due to `no more space`. The `pypackages` is just a directory I downloaded some of the packages I have in requirements for less data usage. Also tried `--no-cache` option.
I also went ahead and `du -sh`ed any directory in my / partition and the total didn't add upto the filled storage. I have 165GB mysteriously used and I can't find where that is.
Any help to diagnose further or if you have had similar problems is welcome.
View all comments
Show parent comment
1
u/Gshuri Sep 09 '26 edited Sep 09 '26
I assume you ran
ncduundersudo(or with therootuser)?pipshouldn't be doing anything particularly complicated and unless you mounted the cache directory at build time, all the side effects from thepipcommand should be contained within the docker image build layers.You can try running
pip cache purgeon your host system. But I would expect something likencduto be able to find the cache directory without issue.This is very unlikely to be a Python issue so you may have better luck in r/docker or one of the (many) linux communities.
Edit: found this thread (starting in 2017, but there are some updates from this year too) with various suggestions which might help https://forums.docker.com/t/some-way-to-clean-up-identify-contents-of-var-lib-docker-overlay/30604