Text of discuss.python.org › t › choosing-a-uv-docker-image › 106004 as Styx crawled it on Nov 20, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

Choosing a `uv` docker image - Python Help - Discussions on Python.org

Choosing a `uv` docker image Python Help jhanarato (Ajahn Jhanarato) February 4, 2026, 12:43pm 1 Hey folks, I’m currently updating a Flask application that runs in a docker container. Currently it uses pip and a `requirements.txt` file and I’m trying to get dependency management setup with uv. The Dockerfile brings in this image: FROM python:3.11.3 I’d like to switch to one of the images here: What would be the most suitable replacement in this case?

Thanks! bwoodsend (Brénainn Woodsend) February 4, 2026, 1:04pm 2 It depends on what your goal is. If minimising container size is important then switching to uv at all is probably going to make it worse. What are your priorities? Size? Auditability? Automated CVE tracking? Symmetry with dev environments? Tight control over dependency versions? Reproducible builds? Do you care which build of Python you get? JamesParrott (James Parrott) February 4, 2026, 1:07pm 3 The normal Python versions are built on top of Debian, so for consistency pick one of those.

I find the Alpine ones work well too, but there can be bugs with MUSL, especially if using C extensions. I found copying the uv binaries from a distroless uv image (like a kind of pre-built build stage) into whatever image I was using previously, worked OK: COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ jhanarato (Ajahn Jhanarato) February 4, 2026, 1:11pm 4 I’d just like to use uv to manage dependencies, nothing fancy.

At this point I have a pyproject.toml file and want to create and use a venv in my container using the usual uv commands, i.e. uv sync I’m not really sure what the python:3.11.3 image actually contains. JamesParrott (James Parrott) February 4, 2026, 1:14pm 5 I’m not really sure what the python:3.11.3 image actually contains. Full fat Debian Buster Image Layer Details - python:3.11.3 (apologies) bwoodsend (Brénainn Woodsend) February 4, 2026, 2:42pm 6 Just dependencies or Python itself too? jamestwebber (James Webber) February 4, 2026, 2:46pm 7 This is the way.

Use whatever slim base image you need and copy in the uv binaries. JamesParrott (James Parrott) February 4, 2026, 2:59pm 8 This is the way. jhanarato (Ajahn Jhanarato) February 4, 2026, 11:47pm 9 I would like to use uv to manage Python versions, yes. bwoodsend (Brénainn Woodsend) February 5, 2026, 12:04pm 10 I’d aim for distroless ghcr.io/astral-sh/uv then since any existing Python installations will end up being ignored in favour of the one(s) you get uv to install. jhanarato (Ajahn Jhanarato) February 6, 2026, 3:00am 11 That sounds good.

How would I make sure that the container uses the environment created by uv sync ? JamesParrott (James Parrott) February 6, 2026, 11:18am 12 Start jobs with uv run in the same dir. Or use --project flags etc. to be sure. johnthagen (John Hagen) February 6, 2026, 2:38pm 13 Here’s an example that uses multiple stages to keep uv and build dependencies out of the final image. It uses the official CPython runtime rather than uv managed python-build-standalone python-blueprint/Dockerfile at main · johnthagen/python-blueprint · GitHub bwoodsend (Brénainn Woodsend) February 6, 2026, 2:53pm 14 Again, it’s up to you.

You can use uv run or prepend .venv/bin to PATH or symlink .venv/bin/{python,flask,anythingelseyouwant} into /usr/bin or just use full paths. It’s distroless and only contains one Python installation so the usual concerns about mixing up Python versions or clobbering system package manager owned files don’t apply.