🌐
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%
🌐
Astral
docs.astral.sh › uv › guides › integration › docker
Using uv in Docker | uv
2 weeks ago - uv provides both distroless Docker images, which are useful for copying uv binaries into your own image builds, and images derived from popular base images, which are useful for using uv in a container. The distroless images do not contain anything but the uv binaries. In contrast, the derived images include an operating system with uv pre-installed. As an example, to run uv in a container using a Debian-based image:
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
Docker + uv - virtual environments
you can also just RUN pip install uv in the docker image to make things a bit simpler too. More on reddit.com
🌐 r/django
14
10
January 11, 2025
PSA: If you're starting a new project, try astral/uv!
At this point there's little reason not to use uv. More on reddit.com
🌐 r/Python
126
347
October 10, 2024
How do I manage a monorepo with multiple subprograms, each of which needs its own docker image?
At first I tried the uv package manager which has a workspace feature, but it is not possible to have separate docker images (as far as I've understand it) because you have one single lock file. There's nothing about having a single lockfile that prevents you from having mulitple dockerfiles. let's pretend we have this: monorepo ├── subproject1 │ ├── file1.py │ ├── file2.py │ ├── Dockerfile │ └── pyproject.toml ├── subproject2 │ ├── file1.py │ ├── file2.py │ ├── Dockerfile │ └── pyproject.toml └── pyproject.toml └── uv.lock You can still build each dockerfile with the uv.lock file, you just need to execute the dockerfiles from the context of monorepo eg docker build -t exampletag -f ./subproject<1|2>/Dockerfile .. now the dockerfile will have access to the monorepo's uv.lock file as well as all the contents of every subfolder. You will need to path everything in the dockerfile as if it was in the parent folder though. That's the only downside to this. Alternatively you can copy the uv.lock into the subfolders as part of some sort of pipeline job. Another option is to use build contexts . though depending on the docker pipeline this may add additional unwanted complexity if you don't wanna do multi-stage pipelines There may be some nuances I'm missing since I don't use uv or work on a monorepo with python but that should be the gist of it More on reddit.com
🌐 r/learnpython
7
5
November 5, 2024
🌐
GitHub
github.com › astral-sh › uv-docker-example › blob › main › Dockerfile
uv-docker-example/Dockerfile at main · astral-sh/uv-docker-example
An example of using uv in Docker images. Contribute to astral-sh/uv-docker-example development by creating an account on GitHub.
Author   astral-sh
🌐
Hynek
hynek.me › articles › docker-uv
Production-ready Python Docker Containers with uv
September 24, 2024 - In case you wonder why I use virtual environments inside of Docker, I wrote it up for you. This workflow used to be tricky before uv 0.4.4 (readers of previous versions of this article will remember), but then it introduced the UV_PROJECT_ENVIRONMENT environment variable and made it a supported workflow.
🌐
Depot
depot.dev › docs › container-builds › how-to-guides › optimal-dockerfiles › python-uv-dockerfile
Optimal Dockerfile for Python with uv | Container Builds | Depot Documentation
This means that even when a layer needs to be rebuilt, your package manager only fetches what's new or updated. This Dockerfile uses the following cache mount syntax: RUN --mount=type=cache,target=/root/.cache/uv \ uv sync --no-install-project --no-devCopy code
🌐
Medium
medium.com › @shaliamekh › python-package-management-with-uv-for-dockerized-environments-f3d727795044
Python package management with uv for dockerized environments | by Raman Shaliamekh | Medium
December 3, 2024 - # docker/compose.yaml --- services: uv-example: container_name: uv-example build: context: ../ dockerfile: docker/Dockerfile volumes: - ../src:/home/uv-example-user/src ports: - 8010:8000 healthcheck: test: ["CMD", "curl", "-f", "localhost:8000/healthcheck"] interval: 30s timeout: 5s retries: 5
🌐
GitHub
github.com › astral-sh › uv-docker-example › blob › main › multistage.Dockerfile
uv-docker-example/multistage.Dockerfile at main · astral-sh/uv-docker-example
An example of using uv in Docker images. Contribute to astral-sh/uv-docker-example development by creating an account on GitHub.
Author   astral-sh
🌐
GitHub
github.com › shaunhegarty › uv-docker-examples
GitHub - shaunhegarty/uv-docker-examples: Some single and multi stage Dockerfile examples using uv · GitHub
-f Dockerfile.multi.python.alpine -t uv-multi-python-alpine docker run --rm uv-multi-python-alpine
Author   shaunhegarty
Find elsewhere
🌐
Medium
medium.com › @benitomartin › deep-dive-into-uv-dockerfiles-by-astral-image-size-performance-best-practices-5790974b9579
Deep Dive into uv Dockerfiles by Astral: Image Size, Performance & Best Practices | by Benito Martin | Medium
March 18, 2025 - FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS builder ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy # Disable Python downloads, because we want to use the system interpreter # across both images. If using a managed Python version, it needs to be # copied from the build image into the final image; see `standalone.Dockerfile` # for an example.
🌐
Josh Kasuboski
joshkasuboski.com › posts › distroless-python-uv
Building a Python Docker Image with Distroless and Uv | Josh Kasuboski
March 8, 2025 - /app RUN --mount=type=cache,target=/root/.cache/uv \ uv sync --frozen --no-dev --no-editable # Then, use a final image without uv FROM gcr.io/distroless/cc # Copy the Python version COPY --from=builder --chown=python:python /python /python WORKDIR /app # Copy the application from the builder COPY --from=builder --chown=app:app /app/.venv /app/.venv # Place executables in the environment at the front of the path ENV PATH="/app/.venv/bin:$PATH" # Run the FastAPI application by default CMD ["fastapi", "run", "--host", "0.0.0.0", "/app/.venv/lib/python3.12/site-packages/uv_docker_example"]
🌐
Docker Hub
hub.docker.com › r › astral › uv
astral/uv - Docker Image
See the available images documentation⁠ for a description of uv's Docker image tagging scheme.
🌐
Mkennedy
mkennedy.codes › home › posts › docker images using uv's python
Docker images using uv's python • Michael Kennedy's Thoughts on Technology
February 5, 2026 - RUN uv pip install -r requirements.txt # These packages do have their versions pinned, but mostly overlap with latest because I'm not a monster. Here’s an example you can play with that runs the “Hello World” Flask app with Granian in Docker:
🌐
GitHub
github.com › astral-sh › uv-docker-example › blob › main › compose.yml
uv-docker-example/compose.yml at main · astral-sh/uv-docker-example
An example of using uv in Docker images. Contribute to astral-sh/uv-docker-example development by creating an account on GitHub.
Author   astral-sh
🌐
Microsoft Developer Blogs
devblogs.microsoft.com › dev blogs › ise developer blog › dockerizing uv
Dockerizing UV - ISE Developer Blog
June 12, 2025 - This ensures that if only your application code changes while dependencies remain the same, Docker can cache the layer where dependencies were installed, leading to faster rebuilds. Use uv venv for Isolation: In the build stage, consider installing dependencies into a virtualenv path. For example, set an env variable ENV VIRTUAL_ENV=/opt/venv and do uv venv $VIRTUAL_ENV then uv pip install -r requirements.txt.
🌐
Python for Data Science
python4data.science › en › 24.3.0 › productive › envs › uv › docker.html
Python Docker Container with uv - Python for Data Science 24.3.0
For example, the build cache mount prevents all wheels from having to be rebuilt if the layer with your dependencies has to be rebuilt. ... The dependencies are synchronised without the application itself.
🌐
GitHub
github.com › astral-sh › uv-docker-example › activity
Activity · astral-sh/uv-docker-example
An example of using uv in Docker images. Contribute to astral-sh/uv-docker-example development by creating an account on GitHub.
Author   astral-sh
🌐
GitHub
github.com › astral-sh › uv › blob › main › docs › guides › integration › docker.md
uv/docs/guides/integration/docker.md at main · astral-sh/uv
COPY --from=ghcr.io/astral-sh/uv:0.11.7 /uv /uvx /bin/ ... While the Dockerfile example above pins to a specific tag, it's also possible to pin a specific SHA256. Pinning a specific SHA256 is considered best practice in environments that require ...
Author   astral-sh
🌐
Uvicorn
uvicorn.dev › deployment › docker
Docker - Uvicorn
docker build -t my-app . docker run -p 8000:8000 my-app · For more information on using uv with Docker, refer to the official uv Docker integration guide.