Python docker image /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 is used to add new files from your machine to the image, such as a configuration file. I'll call it my-customized-tensorflow, but you can name it anything you like. 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. Recommended base image. In both cases you'll still probably want to be root. and your image should be created. 9-alpine WORKDIR /myapp COPY Pipfile Pipfile. If you want to execute it on your local computer, use docker run . /code/ # Install uWSGI RUN pip install uwsgi # Install . 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). 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. 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. Web. 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 . lock . Dependencies will work without problems, because they will be covered by python's default search paths. 2nd image: copy all compiled/built packages from the first image to the second, without the compilers themselves (gcc, postgers-dev, python-dev, etc. If you call /path/to/venv/bin/pip (note the the full venv path) you'll likely find success. . 0 . 8. Your image should be visible under docker images . ) The final objective is to have a smaller image, running python and the python packages that I need. Build and tag the new image. An image created from it would look like the following. # copy the python environment we've prepared COPY --from=python /venv /python # other configurations # ENTRYPOINT ["dotnet", "project. FROM python:3. Doing so can decrease the size of your container image. Give it a new name of your choosing. 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. uhfi bbp ktfxril azyczp usa omp evqfw kqda lxwqi ayp