jupyter / docker-stacks

Ready-to-run Docker images containing Jupyter applications

Home Page:https://jupyter-docker-stacks.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JupyterHub and DockerSpawner - container is not started

nicolajthulin opened this issue · comments

What docker image(s) are you using?

datascience-notebook, scipy-notebook

Host OS system

Ubuntu 22.04

Host architecture

x86_64

What Docker command are you running?

I have just updated the environment, and now containers does not start up. When i check the docker logs i get error:

WARNING: using start-singleuser.sh instead of start-notebook.sh to start a server associated with JupyterHub.
Entered start.sh with args: jupyterhub-singleuser --ip=0.0.0.0 --hub-api-url=http://172.17.0.1:8081/hub/api
Running hooks in: /usr/local/bin/start-notebook.d as uid: 1000 gid: 100
Done running hooks in: /usr/local/bin/start-notebook.d
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: jupyterhub-singleuser --ip=0.0.0.0 --hub-api-url=http://172.17.0.1:8081/hub/api
usage: jupyterhub-singleuser [-h] [--debug] [--show-config]
                             [--show-config-json] [--generate-config] [-y]
                             [--allow-root] [--no-browser] [--autoreload]
                             [--script] [--no-script]
                             [--log-level ServerApp.log_level]
                             [--config ServerApp.config_file]
                             [--ip ServerApp.ip] [--port ServerApp.port]
                             [--port-retries ServerApp.port_retries]
                             [--sock ServerApp.sock]
                             [--sock-mode ServerApp.sock_mode]
                             [--transport KernelManager.transport]
                             [--keyfile ServerApp.keyfile]
                             [--certfile ServerApp.certfile]
                             [--client-ca ServerApp.client_ca]
                             [--notebook-dir ServerApp.root_dir]
                             [--preferred-dir ServerApp.preferred_dir]
                             [--browser ServerApp.browser]
                             [--pylab ServerApp.pylab]
                             [--gateway-url GatewayClient.url]
                             [extra_args ...]
jupyterhub-singleuser: error: unrecognized arguments: --hub-api-url=http://172.17.0.1:8081/hub/api

How to Reproduce the problem?

When I try to run with the old docker images ~9 months old, it runs like a charm. But when I try the one created 30 hours ago (23/09/11) it fails.

Command output

No response

Expected behavior

No response

Actual behavior

The container doesn't start

Anything else?

No response

Latest Docker version

  • I've updated my Docker version to the latest available, and the issue still persists

@nicolajthulin have you updated jupyterhub version/image as well?
I think you might have troubles if you're using old jupyterhub instance with new single user images.

I am running 4.0.2, and it seems to be the same in the new images. It looks like the "hub-api-url" argument have been renamed or removed.

I think so as well. Do you change in the config arguments passed to single user instances?

I have the following spawner configs

c.MyDockerSpawner.hub_ip_connect = '172.17.0.1'
c.MyDockerSpawner.container_image = 'jupyter/datascience-notebook:latest'
notebook_dir = '/home/jovyan'
c.MyDockerSpawner.notebook_dir = notebook_dir
c.MyDockerSpawner.volumes = { 'jupyterhub-user-{username}': notebook_dir }

from dockerspawner import DockerSpawner

class MyDockerSpawner(DockerSpawner):
    def start(self):
        # username is self.user.name
        team = 'shared'
        # add team volume to volumes
        self.volumes['jupyterhub-team-{}'.format(team)]= '/home/jovyan/shared'
        return super().start()

c.JupyterHub.spawner_class = MyDockerSpawner

Just tested with some hub tags:
hub-3.1.1: working
hub-4.0.0: not working - same error as 4.0.2

It seems that c.DockerSpawner.hub_ip_connect was deprecated in favour of JupyterHub.hub_connect_ip a long time ago. Maybe it stopped working.
https://github.com/jupyterhub/dockerspawner/blob/main/docs/source/changelog.md#090---2017-08-20

Could you please try setting JupyterHub.hub_connect_ip instead?

@minrk could you take a look please?

JupyterHub 4.0 ships with jupyterhub-singleuser as a Jupyter Server extension (used by default with Jupyter Server >=2), so it only has standard jupyter-server CLI options, which is why this deprecated option has stopped working. You can opt into the old subclass implementation by setting JUPYTERHUB_SINGLEUSER_EXTENSION=0 in the singleuser environment.

DockerSpawner.hub_ip_connect was deprecated in favor of JupyterHub.hub_connect_ip in JupyterHub 0.8 (2017), so I'd use the non-deprecated option instead.

jupyterhub/dockerspawner#499 removes the old, deprecated option which has stopped working.

Thank you @minrk 👍

@nicolajthulin please check if it works for you and close the issue if everything is fine now.

Btw, container_image is also deprecated, so I recommend you to start using image, so it is less likely to break in the future.
https://jupyterhub-dockerspawner.readthedocs.io/en/latest/api/index.html#dockerspawner.DockerSpawner.container_image

I have change the parameter presented here, but i also needed to update the "dockerspawner.py" file from:

   def get_args(self): 
        args = super().get_args() 
        if self.hub_ip_connect: 
            # JupyterHub 0.7 specifies --hub-api-url 
            # on the command-line, which is hard to update 
            for idx, arg in enumerate(list(args)): 
                if arg.startswith("--hub-api-url="): 
                    args.pop(idx) 
                    break 
            args.append("--hub-api-url=%s" % self._public_hub_api_url()) 
        return args 

I have changed it to:

    def get_args(self): 
        args = super().get_args() 
        if self.hub_ip_connect: 
            # JupyterHub 0.7 specifies --hub-api-url 
            # on the command-line, which is hard to update 
            for idx, arg in enumerate(list(args)): 
                if arg.startswith("--JupyterHubSingleUser.hub_activity_url="): 
                    args.pop(idx) 
                    break 
            args.append("--JupyterHubSingleUser.hub_activity_url=http://172.17.0.1:8081/hub/api") 
        return args 

I don't know how to suggest/implement this in the project, but it works for me know. Should I mark this as resolved?

Greets,
Nicolaj

Hej,

The change to dockerspawner.py in not needed, works with the parameters change only.