astral-sh / astral-sh/uv-docker-example

Using a .devcontainer setup causes issues with volume mounts for .venv within the dev container.

Open
#40 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dockerfile
Stars
809
Forks
84
PR merge metrics
No merged PRs in 30d

Description

I tried to define a dev container setup with vscode for development. The purpose is to define a template to use uv to develop python projects (source code layout) within a devcontainer with vs code alongside without using vs code. Therefore I want to define a dev container setup with a Docker.debug, docker-compose.yml and devcontainer.json file.

**Issue:**
The "new (in the container)" create .venv to reflect the container os does neither exists in the defined (standard) root folder of the project when creating it in the config of the devcontainer.json via the `"postCreateCommand": {"uv-sync--frozen--no-install-project": "uv sync --frozen --no-install-project"}` nor when using the terminal within the running container `uv sync --frozen --no-install-project`. The .venv file is excluded during build by using .dockerignore. The mount should enable volume bind for the project code on the one side and a separate mount of the container .venv should persist the .venv within the container.

Find the setup in the git repo:
https://github.com/tiefenthaler/dev-container-uv-datascience/tree/venv-mount-issue

FYI: The repo also contains the use of docker for production, which all works perfekt.

Would be great for any information how to solve this issue.

Contributor guide

No contributing guide indexed for this repository

Research direction

Inspect the venv-mount-issue branch in the linked repository, starting with Docker.debug, docker-compose.yml, devcontainer.json, and .dockerignore. Run the reported uv sync --frozen --no-install-project command through postCreateCommand and the container terminal, then compare the resulting .venv location and persistence with the intended volume mounts. Done means the container uses the intended project bind mount and a separate persistent .venv mount.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, docker-compose, python
Domain
developer-experience, devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.