Inspecting jupyter server logs from within a container

Hi all,

I’m hosting a small jupyterhub instance on a single node, which uses a DockerSpawner for single user containers, and also gives users sudo. Our image is based on jupyter/docker-stacks. I would like to know if it’s possible for users to view their server logs. The documentation mentions getting server logs via docker logs user-container, but that is obviously not an option for a regular user.

I have tried tail -f /proc/<server_pid>/fd/1, but I’ve gotten a permission denied even though it should be the same user.

The easiest way is probably to build your image with a custom entrypoint that runs Jupyter but duplicates stdout/stderr to also go to a log file inside the container that the user can read.

3 Likes

In case it’s useful this is how it’s done in repo2docker:

Be aware it’s specific to the repo2docker environment, and you may find just using shell redirection with tee works fine!

1 Like

I’ve opened a feature request in jupyter_server related to this: Enable users to access the jupyter server logs · Issue #684 · jupyter-server/jupyter_server · GitHub

1 Like