1. Home
  2. Machine Learning
  3. How to create a Docker image to run Jupyter kernels

How to create a Docker image to run Jupyter kernels

This article demonstrates a procedure to create a Docker image which can be used to run Jupyter kernels via Kubernetes.

Some sample Docker files for creating Jupyter kernel compatible images can be found in the following directories:


In addition to the Docker images mentioned in the sample Docker files, any other suitable image can also be used. For example, a Rocky Linux image based Dockerfile can be created as follows:

FROM rockylinux:latest

CMD ["/bin/bash"]

RUN yum install -y epel-release

RUN yum install -y python36-devel curl gcc python3-distutils-extra tigervnc-server

COPY files/requirements.py3.txt /tmp/requirements.py3.txt

RUN pip3 install -r /tmp/requirements.py3.txt

COPY files/ipykernel-k8s.py /ipykernel-k8s.py

Once the Docker file and other relevant files are in place, the image can be built with the desired name and tag, and pushed to a Docker registry as follows (“registry hostname”, “registry port”, “image name” and “tag” need to be replaced with the appropriate hostname, port, image name and tag; to setup a Docker or a Container Registry on a Bright cluster, please follow the Bright admin manual chapter on Containerization):

# docker build -t <registry hostname>:<registry port>/<image name>:<tag> .
# docker push <registry hostname>:<registry port>/<image name>:<tag>

By this way a Docker image can be created to run Jupyter kernels on Kubernetes. New Jupyter kernel templates with the created image can be created by following the Bright admin manual chapter on Jupyter Notebook Environment Integration.

Updated on March 23, 2022

Related Articles

Leave a Comment