🌐
Astral
docs.astral.sh › uv › guides › integration › docker
Using uv in Docker | uv
2 weeks ago - As with the distroless image, each derived image is published with uv version tags as ghcr.io/astral-sh/uv:{major}.{minor}.{patch}-{base} and ghcr.io/astral-sh/uv:{major}.{minor}-{base}, e.g., ghcr.io/astral-sh/uv:0.11.7-alpine. In addition, starting with 0.8 each derived image also sets UV_TOOL_BIN_DIR to /usr/local/bin to allow uv tool install to work as expected with the default user. For more details, see the GitHub Container page. Use one of the above images with uv pre-installed or install uv by copying the binary from the official distroless Docker image: Dockerfile ·
🌐
GitHub
github.com › andgineer › docker-python-base
GitHub - andgineer/docker-lean-python: Docker Alpine Linux lightweight Python container with UV · GitHub
Extremely small Docker Container, based on Alpine Linux. Includes the high-speed Astral uv Python package manager.
Author   andgineer
Discussions

Best practices for using Python & uv inside Docker
You’re skipping past the first solution they offer, which is the more efficient distroless solution. You can literally just copy the standalone uv binary directly into your image; you don’t need to base your entire image on theirs. COPY --from=ghcr.io/astral-sh/uv:0.9.2 /uv /bin/ This takes ~43MiB, not the 77MiB you cite. More on reddit.com
🌐 r/Python
110
186
October 11, 2025
Unable to run uv managed Python on an Alpine based image.
To replicate the issue, run the following: docker run --rm -it alpine ash # inside the container, setup uv... apk update apk add --no-cache curl curl -LsSf https://astral.sh/uv/install.sh | sh sour... More on github.com
🌐 github.com
1
August 25, 2024
Publish variants of Docker image
Instead of only supplying a bare image, we should publish an alpine variant and a variant with Python so people can use our image without creating a custom derivative. More on github.com
🌐 github.com
8
July 30, 2024
Installing dependencies with `uv sync` system-wide in a Docker image
UV pip compile pyproject > requirement.txt UV pip install -r requirement.txt More on reddit.com
🌐 r/learnpython
20
10
January 6, 2025
🌐
Hynek
hynek.me › articles › docker-uv
Production-ready Python Docker Containers with uv
September 24, 2024 - 2024-09-04: Adapted to 0.4.4’s UV_PROJECT_ENVIRONMENT feature. I’m using Ubuntu as a base image because that’s what I do at work. We have our own base images and PPAs outside of Docker, so it makes sense to stick to one platform. Use whatever you want, just for Cthulhu’s sake stay away from Alpine-based ones.
🌐
Docker Hub
hub.docker.com › r › astral › uv
astral/uv - Docker Image
The official Docker image for uv, the Python package manager.
🌐
Digon
digon.io › en › blog › 2025_07_28_python_docker_images_with_uv
Build Multistage Python Docker Images Using UV
July 27, 2025 - # 3.13.5-alpine3.22 FROM python@sha256:610020b9ad8ee92798f1dbe18d5e928d47358db698969d12730f9686ce3a3191 AS builder # 0.8.3 COPY --from=ghcr.io/astral-sh/uv@sha256:ef11ed817e6a5385c02cd49fdcc99c23d02426088252a8eace6b6e6a2a511f36 /uv /uvx /bin/ ENV UV_LINK_MODE=copy \ UV_COMPILE_BYTECODE=1 \ UV_PYTHON_DOWNLOADS=never WORKDIR /app COPY pyproject.toml uv.lock ./ RUN uv sync --no-dev --locked --no-editable --no-install-project COPY README.md src ./ RUN uv sync --no-dev --locked --no-editable RUN uv run --no-sync generate_openapi_json # 3.13.5-alpine3.22 FROM python@sha256:610020b9ad8ee92798f1dbe18d
🌐
GitHub
github.com › Mgldvd-Docker › alpine-python3.12-uv
GitHub - Mgldvd-Docker/alpine-python3.12-uv: Lightweight Docker image based on Alpine and Python 3.12, integrating uv and a CLI environment for working with Python. Creates a ready-to-use container for developing and running Python projects. · GitHub
Lightweight Docker image based on Alpine and Python 3.12, integrating uv and a CLI environment for working with Python. Creates a ready-to-use container for developing and running Python projects. - Mgldvd-Docker/alpine-python3.12-uv
Author   Mgldvd-Docker
Find elsewhere
🌐
GitHub
github.com › astral-sh › uv › issues › 6595
Unable to run uv managed Python on an Alpine based image. · Issue #6595 · astral-sh/uv
August 25, 2024 - To replicate the issue, run the following: docker run --rm -it alpine ash # inside the container, setup uv... apk update apk add --no-cache curl curl -LsSf https://astral.sh/uv/install.sh | sh source $HOME/.cargo/env uv python install 3....
Author   narigama
🌐
Microsoft Developer Blogs
devblogs.microsoft.com › dev blogs › ise developer blog › dockerizing uv
Dockerizing UV - ISE Developer Blog
June 12, 2025 - Solution: Structure your Dockerfile to take advantage of caching. Separate copying of dependency specifications and the installation step. Missing build tools or UV installation issues: UV is written in Rust, and installing it may fail on slim base images or Alpine Linux.
🌐
Codemageddon
codemageddon.me › post › uv-pdm-docker
How to Build a Perfect Docker Image for your UV/PDM Project :: Codemageddon's corner - Codemageddon's blog
September 29, 2024 - In conclusion, this guide provides Dockerfile templates for both UV and PDM projects, using either Debian or Alpine base images. Depending on your project’s complexity, you can choose between the larger Debian images or the lightweight Alpine ones. Be mindful of potential build issues with ...
🌐
Docker Hub
hub.docker.com › r › statpan › uv-alpine-python
statpan/uv-alpine-python - Docker Image
Welcome to the world's largest container registry built for developers and open source contributors to find, use, and share their container images. Build, push and pull.
🌐
Docker
hub.docker.com › layers › astral › uv › python3.13-alpine › images › sha256-09ebb7348f12295475a35f9edc53611df6ad737953664775c79ce01b11824bee
Image Layer Details - astral/uv:python3.13-alpine
Welcome to the world's largest container registry built for developers and open source contributors to find, use, and share their container images. Build, push and pull.
🌐
DEV Community
dev.to › mo7amed_3bdalla7 › efficient-python-dependency-management-with-uv-in-docker-for-fastapi-1oe1
Efficient Python Dependency Management with uv in Docker for FastAPI - DEV Community
March 5, 2025 - By using uv, you can ensure that only the necessary system dependencies are installed, avoiding unnecessary overhead and improving the overall performance of your containerized application. FROM python:3.12-alpine # Install system dependencies required by uv RUN apk add --no-cache curl git # Install uv safely RUN curl -LsSf -o /tmp/install_uv.sh https://astral.sh/uv/install.sh && \ sh /tmp/install_uv.sh && \ rm /tmp/install_uv.sh # Set PATH to include uv ENV PATH="/root/.local/bin:$PATH" # Create app directory and set permissions WORKDIR /app # Copy dependency files first for caching COPY pyproject.toml uv.lock ./ # Install dependencies using uv RUN uv sync --frozen --no-install-project --no-dev --python-preference=only-system # Copy the rest of the project files COPY .
🌐
GitHub
github.com › astral-sh › uv › issues › 5610
Publish variants of Docker image · Issue #5610 · astral-sh/uv
July 30, 2024 - Publish variants of Docker image#5610 · #6053 · Copy link · Labels · help wantedContribution especially encouragedContribution especially encouragedreleasesRelated to building and distributing release artifacts of uvRelated to building and distributing release artifacts of uv · zanieb · opened · on Jul 30, 2024 · Issue body actions · Instead of only supplying a bare image, we should publish an alpine variant and a variant with Python so people can use our image without creating a custom derivative.
Author   zanieb
🌐
Reddit
reddit.com › r/learnpython › installing dependencies with `uv sync` system-wide in a docker image
r/learnpython on Reddit: Installing dependencies with `uv sync` system-wide in a Docker image
January 6, 2025 -

EDIT: See my solution in the comments!

I've loved uv's local DevEx until now, but I can't seem to find the "recommended"/"best" way to create a docker image that installs all my dependencies system-wide (without a venv) in a Docker image.

I've tried with a 'pyproject.toml' (and associated 'uv.lock'):

[project]
name = "api"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
    "fastapi>=0.115.6", 
    etc...
]

[dependency-groups]
dev = [
    "pytest>=8.3.4",
    etc...
]

And a Dockerfile:

FROM ghcr.io/astral-sh/uv:python3.13-alpine

#ENV UV_PROJECT_ENVIRONMENT="/usr/local/bin/" TODO ???
ENV PYTHONUNBUFFERED True

WORKDIR /app
COPY . .
RUN uv sync --locked --python-preference system --no-dev

BUT exec'ing into the image after build, I see no '.venv/' and:

/app # python main.py 
Traceback (most recent call last):
  File "/app/main.py", line 1, in <module>
    from fastapi import FastAPI
ModuleNotFoundError: No module named 'fastapi'
  • Should I be using uv install --system... instead or is that deprecated?

  • Should I use UV_PROJECT_ENVIRONMENT?

  • Should I simply run everything within a venv inside containers somehow?

Any help or suggestions is greatly appreciated!!

🌐
GitHub
github.com › shaunhegarty › uv-docker-examples › blob › main › Dockerfile.multi.python.alpine
uv-docker-examples/Dockerfile.multi.python.alpine at main · shaunhegarty/uv-docker-examples
Some single and multi stage Dockerfile examples using uv - uv-docker-examples/Dockerfile.multi.python.alpine at main · shaunhegarty/uv-docker-examples
Author   shaunhegarty
🌐
Alpine Linux
pkgs.alpinelinux.org › package › v3.21 › community › x86 › uv
uv - Alpine Linux packages
Package details · Depends (3) · so:libbz2.so.1 · so:libc.musl-x86.so.1 · so:libgcc_s.so.1 · Required by (1) · py3-uv · Sub Packages (5) · py3-uv-pyc
🌐
GitHub
github.com › astral-sh › uv-docker-example
GitHub - astral-sh/uv-docker-example: An example of using uv in Docker images · GitHub
An example project for using uv in Docker images, with a focus on best practices for developing with the project mounted in the local image.
Starred by 762 users
Forked by 74 users
Languages   Dockerfile 81.4% | Shell 16.2% | Python 2.4%