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
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
GitHub
github.com › astral-sh › uv › issues › 8737
Request: Official uv devcontainer · Issue #8737 · astral-sh/uv
October 31, 2024 - Would be really cool if we could get an official uv devcontainer for remote development using common IDEs (VS Code, PyCharm). It isn't too difficult to install uv in the Dockerfile by hand but an official option would be great. Currently the Python devcontainers are published version-by-version, so we don't have access to 3.13 yet.
Author rdong8
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
Tigrisdata
tigrisdata.com › blog › dev-containers-python
Standardizing Python Environments with Development Containers | Tigris Object Storage
July 3, 2025 - This editor preconfiguration means you can fix problems like “What version of Python do I need?” or “How do I just install the dependencies?” forever. 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" } // ...
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 - The python:3.12-slim-bookworm base is a Debian Bookworm slim image with Python pre-installed. It is intentionally thin, which is why build-essential is installed explicitly in the next step. ... Setting UV_PROJECT_ENVIRONMENT to /usr/.venv (outside /app) is deliberate: when the dev container bind-mounts the host directory over /app, the virtual environment remains untouched in /usr/.venv.
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. Now that we are using system python in our dev container, we also need to add one step to get the perms setup in CI.
Everyday DevOps
markcallen.com › addpython-project-with-devcontainers-in-vs-code
Adding DevContainers to a Python Project - Everyday DevOps
August 6, 2025 - FROM python:3.12-slim # Install uv. COPY --from=ghcr.io/astral-sh/uv:0.8 /uv /uvx /bin/ WORKDIR /app # Copy dependency file(s) first for caching COPY pyproject.toml uv.lock ./ # Install dependencies in a separate layer RUN uv sync --frozen COPY . . CMD ["uv", "run", "main.py"] No changes are needed; DevContainers can use this as-is.
DeepWiki
deepwiki.com › philippschmalen › devcontainer-python-uv-template › 4.2-dependency-management-with-uv
Dependency Management with uv | philippschmalen/devcontainer-python-uv-template | DeepWiki
February 27, 2026 - It reads dependency specifications from pyproject.toml, resolves the full transitive graph, writes a deterministic lock file (uv.lock), and installs the resolved packages into a virtual environment. Inside the container, the virtual environment is located at /usr/.venv. The interpreter exposed to VS Code and to application code is /usr/.venv/bin/python.
Simon Willison
til.simonwillison.net › github › codespaces-devcontainers
Configuring GitHub Codespaces using devcontainers | Simon Willison’s TILs
August 12, 2025 - { "name": "Python 3.13", "image": "mcr.microsoft.com/devcontainers/python:3.13-bullseye", "features": { "ghcr.io/devcontainers/features/node:1": { "version": "latest" } }, "customizations": { "vscode": { "settings": { "python.defaultInterpreterPath": "/usr/local/bin/python", "python.linting.enabled": true }, "extensions": [ "ms-python.python", "ms-python.vscode-pylance", "ms-python.vscode-python-envs", "GitHub.copilot" ] } }, "postCreateCommand": "pip install uv" }
GitHub
github.com › muetaek0321 › uv-devcontainer-template
GitHub - muetaek0321/uv-devcontainer-template: uvを使用したPython環境のdevcontainer · GitHub
uvを使用したPython環境のdevcontainer. Contribute to muetaek0321/uv-devcontainer-template development by creating an account on GitHub.
Author muetaek0321
Astral
docs.astral.sh › uv › guides › integration › docker
Using uv in Docker | uv
1 week ago - A complete guide to using uv in Docker to manage Python dependencies while optimizing build times and image size via multi-stage builds, intermediate layers, and more.
Hynek
hynek.me › articles › docker-uv
Production-ready Python Docker Containers with uv
September 24, 2024 - Starting with 0.3.0, Astral’s uv brought many great features, including support for cross-platform lock files uv.lock. Together with subsequent fixes, it has become Python’s finest workflow tool for my (non-scientific) use cases. Here’s how I build production-ready containers, as fast ...
DeepWiki
deepwiki.com › philippschmalen › devcontainer-python-uv-template › 2-getting-started
Getting Started | philippschmalen/devcontainer-python-uv-template | DeepWiki
February 27, 2026 - Select the interpreter at /usr/.venv/bin/python. This path is set as the default in devcontainer.json under settings.python.defaultInterpreterPath, so it may already be pre-selected. ... All dependency operations run inside the container. The package manager is uv.
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 - Summary I tried changing an existing devcontainer to use uv instead of pip, and I ran into the error mentioned in ##11599. Initial devcontainer.json with only uv added: { "name": "Example", "image": "mcr.microsoft.com/devcontainers/pytho...
Author jtkiley