Python docker image / COPY is used to add new files from your machine to the image, such as a configuration file. Recommended base image. . As suggested in my comment, you could write a Dockerfile that looks like: FROM python:3 RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir nibabel pydicom matplotlib pillow med2image # Note: we had to merge the two "pip install" package lists here, otherwise # the last "pip install" command in the OP may I have a containerized Python application and a simple Dockerfile based on an official Python image: FROM python:3. Give it a new name of your choosing. and your image should be created. FROM python:3. An image created from it would look like the following. 0 . Web. 8. I'll call it my-customized-tensorflow, but you can name it anything you like. /code/ # Install uWSGI RUN pip install uwsgi # Install . 2nd image: copy all compiled/built packages from the first image to the second, without the compilers themselves (gcc, postgers-dev, python-dev, etc. In both cases you'll still probably want to be root. Build and tag the new image. 9-alpine WORKDIR /myapp COPY Pipfile Pipfile. dll"] Then you can call /python/bin/python <args> from the app. Assuming the Dockerfile is in the current directory, run docker build: $ docker build -t my-customized Then simply execute docker build -t pulkit/scriptname:1. /code/ # Install uWSGI RUN pip install uwsgi # Install 2nd image: copy all compiled/built packages from the first image to the second, without the compilers themselves (gcc, postgers-dev, python-dev, etc. # copy the python environment we've prepared COPY --from=python /venv /python # other configurations # ENTRYPOINT ["dotnet", "project. If you want to execute it on your local computer, use docker run . Dependencies will work without problems, because they will be covered by python's default search paths. Build a venv in your Docker image, and then use thepip corresponding to the target virtualenv for installing packages into that virtualenv. 2 # Set environment variables ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 # Create /app directory, cd and copy app code there RUN mkdir /code WORKDIR /code COPY . Your image should be visible under docker images . If you call /path/to/venv/bin/pip (note the the full venv path) you'll likely find success. Doing so can decrease the size of your container image. Assuming you're not using a base image that comes with python pre-installed, venv is generally redundant when used in a container: the primary purpose of venv is environment isolation, which the container itself already achieves. Since the alpine base image lacks a toml parser we have to use the version of micropipenv that includes the toml extras (micropipenv[toml] instead of micropipenv). ) The final objective is to have a smaller image, running python and the python packages that I need. Running python scripts from dotnet There are two common paths to using pip in Docker: the one you show where you pip install things directly into the "normal" Python, and a second path using a multi-stage build to create a fully-populated virtual environment that can then be COPYed into a runtime image without build tools. lock . tqhbowagedqggatvpjffuyngrzjlrarxwgymkndsyxplfj