Websoft9 / docker-library

Docker Compose examples of selfhosted FOSS based on official image, just run it.
https://www.websoft9.com
Other
31 stars 14 forks source link

Spawn failed: Server at http://127.0.0.1:41445/user/admin/ didn't respond in 30 seconds [jupyterhub] #541

Closed chendelin1982 closed 5 months ago

chendelin1982 commented 6 months ago

Describe the bug

adduser, then login to Jupyterhub, error

image

Spawn failed: Server at http://127.0.0.1:41445/user/admin/ didn't respond in 30 seconds

Event log
Server requested
Spawning server...
Spawn failed: Server at http://127.0.0.1:41445/user/admin/ didn't respond in 30 seconds
chendelin1982 commented 6 months ago

The same error from official issues

zhaojing1987 commented 5 months ago

根据上面的issue链接查找线索:进入容器: 执行:pip install notebook 或者 pip install jupyterlab 效果: image

zhaojing1987 commented 5 months ago

image 官方文档来看,官方镜像不会安装组件,需要自己安装,由于没有安装组件,似乎在初始化的时候,导致连接失败

zhaojing1987 commented 5 months ago

https://github.com/jupyterhub/jupyterhub-deploy-docker 是否可以使用这个?待验证

chendelin1982 commented 5 months ago
zhaojing1987 commented 5 months ago

在 JupyterHub 中,"Spawner" 是一个负责启动单个用户Jupyter服务器实例的组件。当一个用户登录到 JupyterHub 时,Spawner 会为该用户创建一个新的笔记本服务器,并在用户完成后关闭它。这个过程称为 "spawning"。 "single-user servers" 是指为每个用户单独启动的 Jupyter notebook 服务器。JupyterHub 作为一个多用户的笔记本服务器门户,负责认证用户,并且为每个登录的用户启动一个隔离的、单独的 notebook 服务器实例。

zhaojing1987 commented 5 months ago

根据Spawner的不同,安装的方式有很多种: LocalProcessSpawner:在同一台机器上为每个用户启动一个本地进程(在当前容器内部以进程的方式启动 Notebook 服务器) DockerSpawner:使用 Docker 容器来启动 Jupyter Notebook 服务器(每一个用户都会独立运行一个容器来启动 Notebook 服务器) KubeSpawner :在 Kubernetes 集群上启动 Notebook 服务器 SystemdSpawner:使用 systemd 来管理 Jupyter Notebook 服务器的进程 SudoSpawner:允许 JupyterHub 以 root 用户身份启动 Notebook 服务器,然后切换到实际用户 BatchSpawner:适用于高性能计算(HPC)环境

下面只针对前面两种方式提供安装说明: LocalProcessSpawner 安装: 当前compose文件加入即可:

command: 
      sh -c "pip install jupyterlab && jupyterhub"

DockerSpawner安装: 在compose文件加入:

volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./src/jupyterhub_config.py:/srv/jupyterhub/jupyterhub_config.py
command: 
      sh -c "pip install dockerspawner && jupyterhub -f /srv/jupyterhub/jupyterhub_config.py"

在src下创建文件:jupyterhub_config.py

import os

c = get_config()

# Spawn single-user servers as Docker containers
c.JupyterHub.spawner_class = 'dockerspawner.DockerSpawner'
# JupyterHub requires a single-user instance of the Notebook server, so we
# default to using the `jupyterhub/singleuser` image.
c.DockerSpawner.image = 'jupyter/base-notebook'

# Connect containers to the JupyterHub network

network_name = os.environ.get('W9_NETWORK')
c.DockerSpawner.network_name = network_name
c.DockerSpawner.use_internal_ip = True

# Auto delete invalid users
# c.Authenticator.delete_invalid_users = True

# Set JupyterHub Server IP
hub_ip = os.environ.get('W9_ID')
c.JupyterHub.hub_ip = hub_ip
qiaofeng1227 commented 5 months ago

官方Dockerfile, 我们在官方之前做了几个动作,不会对官方容器有影响。