Kernel Sharing Between Docker Containers

Hello,

I have a JupyterHub installation on Debian 12, and I use DockerSpawner so that my users have their own environments. Is it possible to share environments and, therefore, kernels between all these Docker containers?

I have mounted volumes in my configuration file that correspond to the kernel paths, but without success.

Thanks in advance!

It should be possible, but the complexity depends on your container image. As a starting point you’ll need to share the entire Python environment containing the kernel as well as any configuration files.

Thank you for your response. My image is c.DockerSpawner.image = ‘Quay’.

I tried to mount the volumes using:

c.DockerSpawner.volumes = {
‘/home/…/data/{username}’: ‘/home/jupyter/{username}’,
‘/home/…/.local/share/jupyter/kernels’: ‘/home/jovyan/.local/share/jupyter/kernels’,
‘/home/…/.local/share/jupyter/runtime’: ‘/home/jovyan/.local/share/jupyter/runtime’,
‘/opt/anaconda3’: ‘/opt/anaconda3’,
‘/opt/anaconda3/envs’: ‘/opt/conda/envs’,
}

Is this the correct way to define a share? But I keep encountering permission issues.

PermissionError: [Errno 13] Permission denied: ‘/home/jovyan/.local/share/jupyter/runtime/jpserver-7-open.html’ ou
Permission denied: ‘/home/jovyan/.local/share/jupyter/runtime/j
upyter_cookie_secret’
I don’t see any documentation about this point. Could you point me in the right direction?

It sounds like you’re effectively splitting the existing image into two separate filesystems, one inside the container, and one outside. There’s no easy way to do this for an existing container, you’ll need to go through the original Dockerfile(s) and work out all the different locations you’re writing to during your setup.

The Permission denied most likely mean your mounted volume isn’t writeable by the user inside the container.

Depending on what you’ve done you might be able to put some configuration centrally instead of in the user’s home directory, see

Thanks, yes indeed it’s easier with a Dockerfile… Thanks for the link. I not had problems of permissions … :folded_hands: