Available Images
uv provides both distroless images (containing only uv binaries) and derived images (based on popular base images with uv pre-installed).Distroless Images
Derived Images
Installing uv
1
Copy from distroless image
The recommended approach is to copy the uv binary from the official distroless image:For reproducible builds, pin to a specific SHA256:
2
Alternative: Use installer
You can also use the installer script:
Basic Project Setup
1
Install uv and copy project
2
Sync dependencies
3
Set up the entrypoint
Multi-Stage Build with Intermediate Layers
Optimize build times by separating dependency installation from project installation:For Workspaces
When using workspaces, use--frozen and --no-install-workspace:
Production Optimization
Non-Editable Multi-Stage Build
Create smaller production images by excluding source code:Compile Bytecode
Improve startup time by compiling Python bytecode:Caching
Use cache mounts to speed up builds:Development Setup
Using docker run
Mount your project while preserving the container’s virtual environment:Using Docker Compose with Watch
Using uv pip
1
Enable system Python
2
Install packages
3
Install from requirements