How to add Python libraries to Docker image - Stack Overflow
Why we dropped Docker for Python environments
Setting up the docker module in Python
Making library pip-installable vs. creating Docker image with the library inside
How to use Docker with Python?
What is Docker in Python?
What are the best practices of using Docker in Python?
Videos
» pip install docker
To customize an image you generally want to create a new one using the existing image as a base. In Docker it is extremely common to create custom images when existing ones don't quite do what you want. By basing your images off public ones you can add your own customizations without having to repeat (or even know) what the base image does.
Add the necessary steps to a new Dockerfile.
FROM tensorflow/tensorflow:latest-gpu-jupyter RUN <extra install steps> COPY <extra files>RUNandCOPYare examples of instructions you might use.RUNwill run a command of your choosing such asRUN pip install matplotlib.COPYis used to add new files from your machine to the image, such as a configuration file.Build and tag the new image. Give it a new name of your choosing. I'll call it
my-customized-tensorflow, but you can name it anything you like.Assuming the
Dockerfileis in the current directory, rundocker build:$ docker build -t my-customized-tensorflow .Now you can use
my-customized-tensorflowas you would any other image.$ docker run my-customized-tensorflow
Add this to your Dockerfile after pulling the image:
RUN python -m pip install matplotlib
» pip install docker-py