How to add a python module to the FEniCS Docker container?

Hello, How I could add a python module to the Docker container of FEniCS?

I currently run the following command to run the FEniCS docker container:

sudo docker run --name notebook -w /home/fenics -v $(pwd):/home/fenics/shared -d -p 127.0.0.1:8888:8888 quay.io/fenicsproject/stable 'jupyter-notebook --ip=0.0.0.0'

I have tried to install the module vtkplotter with

sudo docker run pip3 install vtkplotter

but I get the error:

Unable to find image 'pip3:latest' locally
docker: Error response from daemon: pull access denied for pip3, repository does not exist or may require 'docker login'.
See 'docker run --help'.

not an expert of docker, maybe this helps:

Don’t know if this is still an issue, but it might help others.

The way I customise my fenics containers is using and modifying the Dockerfile that comes with fenicsproject.
By default, fenicsproject uses the image quay.io/fenicsproject. I’ve modified my fenicsproject to use my own image, that I tagged my-fenics/stable.

Go to ~/.local/bin/fenicsproject and towards the top edit it such that:

# Config
#DEFAULT_IMAGE_HOST="quay.io/fenicsproject"
DEFAULT_IMAGE_HOST="my-fenics"

Then, create a Dockerfile somewhere like the one below (and modify the line where pip3 gets your packages):

FROM quay.io/fenicsproject/stable:latest
USER root
RUN apt-get -qq update && \
    apt-get -y upgrade && \
    apt-get -y install python3-pip && \
    apt-get -y install gmsh python3-lxml python3-h5py && \
    apt-get -y install libcgal-dev libeigen3-dev gmsh && \
    apt autoremove && \
    apt-get clean
RUN pip3 install --upgrade pip && \
    pip3 install -U numpy scipy meshio[all] lxml h5py pygmsh matplotlib tabulate pandas sympy sc
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp*
RUN sed -i "s/ax.set_aspect('equal')/# ax.set_aspect('equal')/g" /usr/local/lib/python3.6/dist-p
USER root

You can make your custom image by running

docker build . -t my-fenics/stable

in the folder where you saved your Dockerfile.

You’ll get longish output where you’ll find errors (if it breaks) or a success message with the image fingerprint.

Now, you can delete your old fenics container (let’s say it was a notebook called fenics-doodeling) and recreate it with your custom, new image:

docker container rm fenics-doodeling
fenicsproject notebook fenics-doodeling

and start using fenicsproject start fenics-doodeling like before.