🌐
GitHub
github.com › astral-sh › uv-docker-example
GitHub - astral-sh/uv-docker-example: An example of using uv in Docker images · GitHub
The run.sh script includes an example of invoking docker run for local development, mounting the source code for the project into the container so that edits are reflected immediately. The compose.yml file includes a Docker compose definition for the web application. It includes a watch directive for Docker compose, which is a best-practice method for updating the container on local changes. The Python application code for the project is at src/uv_docker_example/__init__.py — there's a command line entrypoint and a basic FastAPI application — both of which just display "hello world" output.
Starred by 764 users
Forked by 73 users
Languages   Dockerfile 81.4% | Shell 16.2% | Python 2.4%
🌐
GitHub
github.com › astral-sh › uv-docker-example › blob › main › Dockerfile
uv-docker-example/Dockerfile at main · astral-sh/uv-docker-example
# Use a Python image with uv pre-installed · FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim · · # Setup a non-root user · RUN groupadd --system --gid 999 nonroot \ && useradd --system --gid 999 --uid 999 --create-home nonroot · · # Install the project into `/app` WORKDIR /app ·
Author   astral-sh
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
Adding Python to Docker in 2 seconds using uv's Python command
Hmm this is interesting. I'm wondering if it's worth migrating from poetry to uv for our package management. We also use docker to containerize images for CI/docker compose local stacks. More on reddit.com
🌐 r/Python
45
160
September 7, 2024
cookiecutter-uv: A modern template for quickly starting Python projects with uv
Great work, I'd swap out prettier for biome though as it's JavaScript equivalent rust formatter and linter replacement for prettier and eslint More on reddit.com
🌐 r/Python
14
92
September 4, 2024
UV for Python Project and Version Management
pyproject.toml is a config file used for package builders https://packaging.python.org/en/latest/guides/writing-pyproject-toml/ uv.lock is your exact enviroment config https://docs.astral.sh/uv/guides/projects/#python-version and yes, based on their documents (link above again) This file should be checked into version control, allowing for consistent and reproducible installations across machines. edit: changed system to environment More on reddit.com
🌐 r/learnpython
6
7
March 15, 2025
🌐
Astral
docs.astral.sh › uv › guides › integration › docker
Using uv in Docker | uv
2 weeks ago - Use one of the above images with ... install -y --no-install-recommends curl ca-certificates # Download the latest installer ADD https://astral.sh/uv/install.sh /uv-installer.sh # Run the installer then remove it RUN sh /uv-installer.sh && rm /uv-installer.sh # Ensure the installed ...
🌐
Depot
depot.dev › docs › container-builds › how-to-guides › optimal-dockerfiles › python-uv-dockerfile
Optimal Dockerfile for Python with uv | Container Builds | Depot Documentation
USER appuser ENTRYPOINT ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]Copy code · The runtime stage uses a clean slim image and creates a non-root user for security. We copy the entire application including the virtual environment from the build stage and set proper ownership. Cache mounts in this Dockerfile speed up builds by persisting the package manager cache.
🌐
GitHub
github.com › shaunhegarty › uv-docker-examples
GitHub - shaunhegarty/uv-docker-examples: Some single and multi stage Dockerfile examples using uv · GitHub
uv run effectively runs uv sync before each, meaning we always need to include --no-dev in any case where uv run is used or we'll end up installing the packages in each container or syncing the environment each time uv run is called. ... docker build . -f Dockerfile.multi.python.alpine -t uv-multi-python-alpine docker run --rm uv-multi-python-alpine
Author   shaunhegarty
🌐
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"]
🌐
GitHub
github.com › gdamjan › uv-getting-started › blob › main › Dockerfile
uv-getting-started/Dockerfile at main · gdamjan/uv-getting-started
An example "getting started" python project based on `uv` - uv-getting-started/Dockerfile at main · gdamjan/uv-getting-started
Author   gdamjan
🌐
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
Find elsewhere
🌐
GitHub
gist.github.com › adamghill › 419d02e95b1563ad76b0c36995e829b8
Multi-stage Dockerfile with Python and `uv` · GitHub
Multi-stage Dockerfile with Python and `uv`. GitHub Gist: instantly share code, notes, and snippets.
🌐
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 - mkdir uv-docker-example && cd uv-docker-example \ && mkdir docker src && touch docker/Dockerfile docker/compose.yaml · To initialize the project, let’s start with a minimal Dockerfile.
🌐
Ricky-lim
ricky-lim.github.io › blog › distribute-python-script-with-uv-and-docker
Distribute Python Script with UV and Docker — kutubuku
The example below shows how to leverage uv in the Dockerfile to pre-install dependencies. FROM python:3.12-slim-bookworm COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ WORKDIR /app COPY check_rain .
🌐
GitHub
github.com › astral-sh › uv › blob › main › docs › guides › integration › docker.md
uv/docs/guides/integration/docker.md at main · astral-sh/uv
ENV UV_PYTHON_CACHE_DIR=/root/.cache/uv/python RUN --mount=type=cache,target=/root/.cache/uv \ uv python install ... The cache directory's location can be determined by running the `uv cache dir` command in the container. Alternatively, the cache can be set to a constant location: ```dockerfile title="Dockerfile" ENV UV_CACHE_DIR=/opt/uv-cache/ ```
Author   astral-sh
🌐
GitHub
github.com › philippschmalen › devcontainer-python-uv-template
GitHub - philippschmalen/devcontainer-python-uv-template: Production-ready VSCode Devcontainer with fast and lightweight build using two-staged Docker build with `uv`. Uses `docker-compose` to spin up multiple services. · GitHub
# When prompted, or using the Command Palette (Ctrl+Shift+P), select: # > Dev Containers: Open Folder in Container (or similar) # after build you should see # CTRL+p > Python: Select Interpreter > /home/nonroot/.venv/bin/python (as defined in `Dockerfile`) Add dependencies: uv add <package-name> (runs inside the container)
Author   philippschmalen
🌐
Hynek
hynek.me › articles › docker-uv
Production-ready Python Docker Containers with uv
September 24, 2024 - Anyways, if your application isn’t packaged for whatever reason: I have added inline notes how to adjust the Dockerfile. In a nutshell, instead of installing your application in the build step, you COPY it into the runtime container after COPYing /app over. Be careful to not overwrite /app. P.S. If you need more help with Docker, my friend Itamar Turner-Trauring has great resources for you. 2024-11-12: Added a workaround for #9046: Use absolute paths for UV_PYTHON on uv 0.5.0+.
🌐
GitHub
github.com › a5chin › python-uv
GitHub - a5chin/python-uv: A production-ready Python development environment template using modern tools: uv for blazing-fast package management, Ruff for lightning-fast linting and formatting, ty for fast and reliable type checking, and VSCode Dev Containers for reproducible development environments. · GitHub
# Install dependencies uv sync # Run tests uv run nox -s test # Format and lint uv run nox -s fmt uv run nox -s lint -- --ruff --ty · # Build the image docker build -t python-uv .
Starred by 363 users
Forked by 69 users
Languages   Python 92.5% | Dockerfile 7.5%
🌐
Tiefenthaler
tiefenthaler.github.io › uv-datascience-project-monorepo-template › guides › docker_prod
Docker-Production - UV Data Science Project Mono-Repository Template
x-args: &default-args WORKSPACE_NAME: "app" UV_VER: "python3.12-bookworm" Builds and runs the application using the standard Dockerfile.
🌐
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 - Enter uv by Astral: a modern tool ... speed up Python dependency resolution. It introduces a fresh approach to Docker workflows, but it comes with configuration choices that may be unclear if you are not familiar with how they affect image structure. The uvGitHub repository provides three example Dockerfiles...
🌐
GitHub
github.com › VeryLongDelay › python-uv
GitHub - VeryLongDelay/python-uv: A base Dockerfile with uv and common packages pre-installed
Using this image as a base will allow you to forget about anything required to setup uv within your Docker environment. Simply COPY your pyproject & uv lock file into your image, and uv run. See the examples folder for example usage.
Author   VeryLongDelay
🌐
GitHub
github.com › astral-sh › uv-docker-example › blob › main › pyproject.toml
uv-docker-example/pyproject.toml at main · astral-sh/uv-docker-example
name = "uv-docker-example" version = "0.1.0" description = "Add your description here" readme = "README.md" requires-python = ">=3.11" dependencies = [ "fastapi[standard]>=0.112.2", ] · [build-system] requires = ["hatchling"] build-backend = "hatchling.build" ·
Author   astral-sh