Docker TLJH Reason

Hi. I am running TLJH on a local (powerfull) server as a docker container since few weeks now. I exchanged the base image to use a cuda-enabled one. It’s working like charm.

But since day one I wonder about the statement on the webpage:
Running TLJH inside a docker container is not supported, since we depend on systemd.

Can anyone please let me know why it isn’t supported and why systemd is the reason?

Secondly I saw thread stating “using docker in production environment is not a good choice”. In the local industry here, nearly all the global players use docker in their production environments. So I wonder if I am missing something here?

Thank you very much for your answer!

I am not a user of TLJH but looking at the source code, I can see it uses systemdspawner for spawning single user servers. With this spawner, it is systemd that controls the resource limits using cgroups of each single user server so that one user cannot take all the compute and/or memory of your local server. Also, I see that TLJH uses systemd to run JupyterHub service. So, I assume you installed systemd in Docker container and running systemctl command as your entrypoint? Even if it works for you, I doubt systemd inside your Docker container can limit the resources of each single user server. Atleast not without privileges. If there are no resource limits, one user can potentially bring whole server down by taking all of the available resources.

I guess you will be interested in dockerspawner where each single user server will be spawned inside a docker container and in this case you can run JupyterHub service inside a docker container as well provided that you bind mount docker socket inside the container that you are running JupyterHub service.

1 Like

tljh is specifically a distribution of JupyterHub that uses systemd meant for running in a cloud VM. If you run it in a container, you have to make sure you’ve set up systemd to run multiple services in a single container, which is not really “the container way.” It’s definitely possible, but it’s not supported in that if you have issues with this configuration, we can’t really help, and documenting setting up systemd in a container is not something we’re going to do. If it works fine for you, then there’s no problem.

As for using docker in production, I’m not quite sure what you are referring to, but it’s definitely fine to use JupyterHub with docker in production and this is very common. It’s just not what tljh is for. Usually you’d use something like docker-compose for this, to put the Hub, proxy (maybe even database), and each user in their own container via DockerSpawner.

2 Likes

Thank you so much for the clarification!