Use JupyterHub with non Jupyter Docker Images

Is it possible to use the nvidia/pytorch:23.05-py3 container with JupyterHub? The image exposes the port 8888 and runs jupyter notebook but whenever I try to connect to it with JupyterHub I just get 404. Jupyterhub will the spawn the image but I cant connect to it.

If I were to run the image normally, I can connect to it over port 8888 with the token that it provides.

Is a compatible version of jupyterhub-singleuser (part of the jupyterhub package) installed and in the container’s PATH?

Preface: this is my first time building any container, so please forgive me if some parts seem weird.

Thanks for the response!

It had a version of jupyterlabs installed in the container already but I had to configure it to work with jupyterhub. I essentially used nvidia/pytorch:23.05-py3 as a base, took bits from docker-stacks-foundation and base-notebook, added jupyterhub to the install, and built the docker container.

In the testing I have done so far, I am able to connect to it through jupyterhub and execute python commands as the jovyan user inside the container. I also have my jupyterhub config set to spawn the container as not the root user as well. My end goal was to have it run as non root user inside and out of the container. Not sure if that would be overkill or not but… I have not had the chance to test it out with actual graphics cards yet though. I am not sure if the container would need to be run as root to access pcie devices.

The only issues I have seen pop up in the logs is that it cannot set the user without running as root.

Entered start.sh with args: jupyter lab
Running hooks in: /usr/local/bin/start-notebook.d as uid: 1000 gid: 100
Done running hooks in: /usr/local/bin/start-notebook.d
WARNING: container must be started as root to change the desired user's name with NB_USER=""!
WARNING: container must be started as root to change the desired user's id with NB_UID=""!
WARNING: container must be started as root to change the desired user's group id with NB_GID=""!
Running hooks in: /usr/local/bin/before-notebook.d as uid: 1000 gid: 100
Done running hooks in: /usr/local/bin/before-notebook.d
Executing the command: jupyter lab

The above warnings were shown with running the container I built without jupyterhub. Just running it as a regular container.

I also have to set the workspace directory manually instead of the variables mentioned in the above docker builds for the those containers. I suspect it is due to the issues mentioned above with the user. It is not that big of a deal to set it manually though.

The healthcheck does not work seem to work either.

All in all, as far as I am aware, everything seems to be working with it except for a few minor things. Still have to do some more testing with actual graphics cards though.