Skip to content
Latchkey

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.txt

Common 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.txt

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →