pip install --no-cache-dir: Disable the pip Cache
Skip the cache to keep Docker layers small and avoid stale wheels.
The --no-cache-dir flag tells pip not to read from or write to its cache. It is standard in Dockerfiles to avoid baking the cache into an image layer.
What it does
Disables pip’s wheel and HTTP cache for that invocation. Nothing is written to ~/.cache/pip, so the install leaves no cache files behind in the layer.
Common usage
Dockerfile
pip install --no-cache-dir -r requirements.txtCommon CI gotcha: slower repeated installs
In a Docker build, --no-cache-dir keeps the layer small. In a regular CI job with a persisted, restored cache, using it discards that speedup. Pick based on whether the cache is reused.
Dockerfile
# Docker: keep image small
RUN pip install --no-cache-dir -r requirements.txt
# Persisted-cache CI job: omit the flag to reuse the cache
# pip install -r requirements.txtRelated guides
pip cache purge: Clear pip’s Wheel CacheHow pip cache purge clears pip’s local wheel and HTTP cache, when to use it to reclaim disk on a runner, and…
pip install -r: Install from requirements.txt in CIHow pip install -r installs every dependency from a requirements file, the flags that make it reproducible in…
pip install --only-binary: Force Wheels, Skip BuildsHow pip install --only-binary forces wheel-only installs to avoid slow, fragile source builds in CI, the :all…