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
🌐
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" } // ...
Discussions

python - VSCode devcontainer and UV - Stack Overflow
I'm developing using VSCode's devcontainer, and I used pip with a requirements.txt file for a few years with no problems. Works like charm. I'd like to upgrade to using uv, but I'm encountering a p... More on stackoverflow.com
🌐 stackoverflow.com
Request: Official uv devcontainer
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, ... More on github.com
🌐 github.com
9
October 31, 2024
Template for Python Development with CUDA in Dev Containers
If Pytorch is also needed in the container, the Cresset Template is a lot more flexible, though it runs mamba by default. More on reddit.com
🌐 r/Python
5
1
September 17, 2024
Installing dependencies with `uv sync` system-wide in a Docker image
UV pip compile pyproject > requirement.txt UV pip install -r requirement.txt More on reddit.com
🌐 r/learnpython
20
10
January 6, 2025
🌐
Jeroen Overschie
jeroenoverschie.nl › python-devcontainer-with-uv
Python Devcontainer with uv - Jeroen Overschie
October 2, 2025 - Now that we have a Devcontainer, let's set up our project inside it. ... We can use uv init to scaffold a new Python project. uv init \ --package \ --name example_project \ --description "Example Python Devcontainer project with uv"
🌐
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
🌐
Astral
docs.astral.sh › uv › guides › integration › docker
Using uv in Docker | uv
1 week ago - Use one of the above images with uv pre-installed or install uv by copying the binary from the official distroless Docker image: ... FROM python:3.12-slim-trixie # The installer requires curl (and certificates) to download the release archive RUN apt-get update && apt-get 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 binary is on the `PATH` ENV PATH="/root/.local/bin/:$PATH"
🌐
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 - You’ll see Python 3.11 and the installed packages (numpy, pandas). Team Collaboration: Share the .devcontainer folder in your repository for consistent setups. Clean Up: Delete the container to remove all dependencies, keeping your host system clean. Cross-Platform: Works on Windows, macOS, Linux, or cloud environments. uv ...
Find elsewhere
🌐
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) pre-commit (linting, formatting, testing) runs automatically on commit · want to ignore files that are specific to you without using .gitignore? Add them to .git/info/exclude · Want to use an already authenticated az cli from the host? Add this to the following files: // .devcontainer/devcontainer.json "features": { ...
Author   philippschmalen
🌐
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" }
🌐
Everyday DevOps
markcallen.com › addpython-project-with-devcontainers-in-vs-code
Adding DevContainers to a Python Project - Everyday DevOps
August 6, 2025 - 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 ...
🌐
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.
🌐
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.
🌐
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 ...
🌐
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, ...
Author   rdong8
🌐
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 - Honestly, you might think it’s unnecessary since uv’s virtual environments make it easy to set up environments, but the advantages of devcontainer are reducing OS differences and isolating and aligning VSCode extensions. This template uses devcontainer during coding with VSCode or Cursor to provide a unified Python development environment. devcontainer configuration is written in the .devcontainer/devcontainer.json file. Below is an example of devcontainer.json configuration used in this template.
🌐
Ivan Lee
ivanlee.me › devcontainers-in-2025-a-personal-take
Devcontainers in 2025: A Personal Take - Ivan Lee
March 2, 2025 - A good example of this is the (semi) ubiquitous pre-commit tool which is a 💎 for making linting and formatting a regular part of your development workflow. A post-install script lets you automate away the "little things" that make setting ...
🌐
GitHub
github.com › muetaek0321 › uv-devcontainer-template
GitHub - muetaek0321/uv-devcontainer-template: uvを使用したPython環境のdevcontainer · GitHub
必要なライブラリをインストール インストール時は下記のコマンドを実行 [package]はインストールしたいライブラリ名を入れてください。(numpy, pandasなど) uv add [package]
Author   muetaek0321
🌐
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 - This page covers the `uv` package manager workflow used in this project: how dependencies are declared, locked, installed, and upgraded. It also documents the full transitive dependency graph as recor