Open braaannigan opened 2 weeks ago
Thanks for sharing!
The first issue is that when you run the container you need to activate the virtual env every time
You could add the virtual environment's bin
to the PATH
then you shouldn't need to do any activation.
You can also use --system
and just skip the virtual environment entirely.
The second is that if I want to try out additional package installs while running in interactive mode I have neither uv nor pip available! uv isn't available because it's just a docker build layer and pip is not in the virtual env. The options here are to install pip into the virtual env or to manually install uv from curl when runnng interactively.
Sounds about right. I'd opt to just keep uv around, but the alternative is to run uv venv
with --seed
to install pip
or install pip
manually.
You can also use --system and just skip the virtual environment entirely.
FWIW this is what I'm doing and it works flawlessly.
@zanieb @hoechenberger I've done the add-venv-to-path approach: https://www.rhosignal.com/posts/uv-in-docker/
Any feeling for whether there is a preference for this over the --system approach?
@braaannigan In my dev containers I try to keep complexity low, and I feel like setting up a venv adds another layer of complexity. I therefore set the UV_SYSTEM_PYTHON
env var and install things globally. No need for a venv in an isolated environment like a dev container. I can share a sample dev container config with you if you're interested!
I think both approaches are totally reasonable. We see a "add venv to path" approach more often when you don't have write access to the system.
I'm adding some documentation based on this discussion #4433
Thanks for this great crate! I've been working with a recent version and trying to capture my best practices here: https://www.rhosignal.com/posts/uv-in-docker/
I want to highlight some issues with the more recent versions of uv when working in interactive mode in docker. The issues arise because of the way a virtual env is now required. I want to use the following dockerfile approach (as opposed to a curl installation) as it has better caching:
This works fine for building the image. The problem is when I want to develop in interactive mode in the container (which is my whole day basically).
Have I missed any other possible solutions for dealing with these issues?
Thanks again