When VSCode launches a Dev Container, it bind-mounts your project into /workspaces/<project>, and sets that as the working directory. However, your Dockerfile installs dependencies into /app/.venv, which VSCode doesn't see.
To fix this, simply align your WORKDIR in the Dockerfile with the directory VSCode uses. That way, uv will create the .venv right where VSCode expects it.
Something like this should work:
FROM python:3.12-slim
ADD https://astral.sh/uv/install.sh /install.sh
RUN chmod +x /install.sh && /install.sh && rm /install.sh
ENV PATH="/root/.local/bin:$PATH"
WORKDIR /workspaces/<project>
COPY pyproject.toml ./
RUN uv sync --dev
Answer from aran on Stack OverflowGitHub
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
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 ...
Starred by 363 users
Forked by 69 users
Languages Python 92.5% | Dockerfile 7.5%
Videos
10:49
How To Use uv in Production - Simple Docker Setup - YouTube
13:32
Speed Up Your Python Workflow with UV - YouTube
11:03
uv - Docker setup with a FastAPI application! | Using uv in ...
23:59
How to create a Dev Container for your project in Visual Studio ...
Dev Containers Guide 2026: The ULTIMATE Python ...
23:17
How to Create your First container using Dev Container, Python ...
GitHub
github.com › astral-sh › uv › issues › 8737
Request: Official uv devcontainer · Issue #8737 · astral-sh/uv
October 31, 2024 - Currently the Python devcontainers are published version-by-version, so we don't have access to 3.13 yet. ... releasesRelated to building and distributing release artifacts of uvRelated to building and distributing release artifacts of uvwishNot on the immediate roadmapNot on the immediate roadmap
Author rdong8
GitHub
github.com › astral-sh › uv › issues › 12197
Improve devcontainer experience, particularly when switching from pip to uv. · Issue #12197 · astral-sh/uv
March 15, 2025 - Ideally, a user could simply add a uv feature to a devcontainer, change the postCreateCommand to use uv pip instead of pip, and have it work.
Author jtkiley
Ivan Lee
ivanlee.me › devcontainers-in-2025-a-personal-take
Devcontainers in 2025: A Personal Take - Ivan Lee
March 2, 2025 - Use a base image like mcr.microsoft.com/devcontainers/base:debian-12 and configure your programming languages and tools from scratch. This is particularly useful if you have a very specific dependencies, like to use tooling manage multiple versions (e.g. pyenv or uv while writing a Python library), ...
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
Production-ready VSCode Devcontainer with fast and lightweight build using two-staged Docker build with `uv`. Uses `docker-compose` to spin up multiple services. - philippschmalen/devcontainer-python-uv-template
Author philippschmalen
Simon Willison
til.simonwillison.net › github › codespaces-devcontainers
Configuring GitHub Codespaces using devcontainers | Simon Willison’s TILs
August 12, 2025 - Here I'm using pip to install uv, after which uv tool install X etc will be available. Once you have added a .devcontainer/devcontainer.json to a repository you can construct a link that will launch that repository as a Codespace like so: https://codespaces.new/simonw/codespaces?quickstart=1 ·
Docker Hub
hub.docker.com › r › jfxs › devcontainer-uv
jfxs/devcontainer-uv - Docker Image
.devcontainer/devcontainer.json configuration to develop inside a container: ... lint: desc: "Python lint with Ruff." cmds: - uv run ruff check silent: true format: desc: "Python format with Ruff." cmds: - uv run ruff check --fix - uv run ruff format silent: true Copy
GitHub
github.com › va-h › devcontainers-features › tree › main › src › uv
devcontainers-features/src/uv at main · va-h/devcontainers-features
Enable or disable uv and uvx autocompletion. ... Note: This file was auto-generated from the devcontainer-feature.json.
Author va-h
Dataduel
dataduel.co › home › running uv in dev containers & github actions
Running uv in dev containers & github actions – DataDuel.co
April 24, 2024 - Then you can run `uv pip install --system -r requirements.txt in your devcontainer to add libraries as needed.
GitHub
github.com › dunnkers › python-uv-devcontainer
GitHub - dunnkers/python-uv-devcontainer: Python project setup using a Devcontainer and uv.
Upon opening the Devcontainer, setup will start. Wait for the setup to finish before continuing. ... Enter Ctrl+Shift+P and select Python: Select Interpreter. Select the venv (./.venv/bin/python). ... You now have a fully configured Python development environment! ... A workflow is already set up for you. This workflow runs tests using pytest and formatting + linting using ruff. Dependencies are set up with uv.
Author dunnkers
DeepWiki
deepwiki.com › philippschmalen › devcontainer-python-uv-template › 3.1-dockerfile-multi-stage-build
Dockerfile — Multi-Stage Build | philippschmalen/devcontainer-python-uv-template | DeepWiki
February 27, 2026 - It covers both stages (builder and production), the environment variables set in each, how uv is introduced, and the dependency installation pattern. For how these stages are consumed by Docker Compose — production usage in docker-compose.yml and development usage in .devcontainer/docker-...
Astral
docs.astral.sh › uv › guides › integration › docker
Using uv in Docker | uv
2 days 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.
GitHub
github.com › astral-sh › uv › issues › 2333
Use UV without VENV (devcontainer) · Issue #2333 · astral-sh/uv
March 10, 2024 - error: Failed to locate a virtualenv or Conda environment (checked: VIRTUAL_ENV, CONDA_PREFIX, and .venv). Run uv venv to create a virtualenv. my dev env is a devcontainer, specifically the image mcr.microsoft.com/devcontainers/python:1-3.12-bullseye hosted at https://github.com/devcontainers/images/blob/main/src/python
Author osbyrne
Development Containers
containers.dev › features
Available Dev Container Features
Development containers documentation and specification page.