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 Overflow
🌐
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
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%
🌐
Medium
medium.com › @ebojacky › revolutionizing-software-development-a-deep-dive-into-development-containers-uv-and-just-9c53b5f78b8f
Revolutionizing Software Development: A Deep Dive into Development Containers, uv, and just | by Ebo Jackson | Medium
June 11, 2025 - Cross-Platform: Works on Windows, macOS, Linux, or cloud environments. uv is a high-performance Python package and environment manager designed to replace tools like Poetry, Conda, and venv.
🌐
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
🌐
Jeroen Overschie
jeroenoverschie.nl › python-devcontainer-with-uv
Python Devcontainer with uv - Jeroen Overschie
October 2, 2025 - Our Devcontainer automatically installs Python, uv and ruff.
🌐
Medium
daniel-mannino.medium.com › better-python-programming-with-dev-containers-uv-and-ruff-a56ed7172d9e
Better Python programming with Dev Containers, uv, and ruff | by Daniel Mannino | Medium
December 6, 2024 - This article describes my macbook setup for coding in Python. The setup leverages VScode, Dev Containers, uv, and ruff.
🌐
Tigrisdata
tigrisdata.com › blog › dev-containers-python
Standardizing Python Environments with Development Containers | Tigris Object Storage
July 3, 2025 - Take tigrisdata-community/huggingface-datasets-with-tigris for example. Its devcontainer.json answers that question for you: { // ... "postCreateCommand": "uv python install && uv venv && uv sync", "remoteEnv": { "UV_LINK_MODE": "copy", "UV_PYTHON": "3.10" } // ...
🌐
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
Find elsewhere
🌐
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
🌐
Mjunya
mjunya.com › en › posts › 2025-06-15-python-template
Modern Python Development Environment Template with uv, ruff, devcontainer, Claude Code | MJUN Tech Note
June 15, 2025 - The devcontainer.json file contains any needed metadata and settings required to configure a development container for a given well-defined tool and runtime ... ... A guide to using uv with PyTorch, including installing PyTorch, configuring ...
🌐
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.