Do not overwrite Python libraries already installed in a Docker container #9151
Replies: 2 comments
-
|
Does https://python-poetry.org/docs/configuration/#virtualenvsoptionssystem-site-packages work for you? This will only work if your system site packages have the same versions as in the Alternative, if you do not care about the locked versions, is to install the project as a wheel (or directly via pip). Here is an untested snippet. FROM docker.io/python:3.12 as build
COPY ./ /opt/app
WORKDIR /opt/app
RUN pip install build
RUN python -m build .
FROM nvcr.io/nvidia/pytorch:24.02-py3 AS runtime
RUN mkdir -p /opt/app
COPY --from=build /opt/app/*.whl /opt/app/
WORKDIR /opt/app
RUN python -m venv --system-site-packages .venv
RUN .venv/bin/python -m pip install /opt/app/*.whl |
Beta Was this translation helpful? Give feedback.
-
|
if you want to install your project without respecting the lockfile, simply |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm using a Docker image provided by Nvidia, optimized for deep learning purposes. This Docker image has pinned some dependencies that work well together and some other OS optimization. I would like, therefore, to only add new Python dependencies without overwriting the existing ones. Is it possible to achieve that with
poetry?For instance, the container already has these (and more) Python libraries installed.
This is the command I use to install
poetryin the Dockerfile:... and this is the
pyproject.toml:My ideal workflow would be:
docker build ...docker run ...docker exec -it ... /bin/bashpoetry add ...and then lock them withpoetry lockdocker build ...docker run ...docker exec -it ... /bin/bashThis is already possible with
poetry. My only challenge is that I want to tellpoetrynever to overwrite those Python libraries that Nvidia pre-installed in the container and just use them.Beta Was this translation helpful? Give feedback.
All reactions