jupyterhub / jupyterhub-deploy-docker

Reference deployment of JupyterHub with docker
BSD 3-Clause "New" or "Revised" License
701 stars 368 forks source link

Bad config encountered during initialization: The 'spawner_class' trait of <jupyterhub.app.JupyterHub object at 0x7f1437bfab80> instance must be a type, but 'dockerspawner.DockerSpawner' could not be imported #109

Closed Mokyyds closed 3 years ago

Mokyyds commented 3 years ago

Please help me, I want to deploy JupyterHub in Docker, and I get an error when starting: Bad config encountered during initialization: The'spawner_class' trait of <jupyterhub.app.JupyterHub object at 0x7f1437bfab80> instance must be a type, but'dockerspawner.DockerSpawner' could not be imported My docker-compose.yaml file:

version: '3.1'
services:
  jupyterhub:
    container_name: jupyterhub
    restart: always
    image: jupyterhub/jupyterhub
    ports:
      - 7003:8000
      - 8081:8081
    volumes:
      - /usr/local/docker/jupyterhub/data:/srv/jupyterhub
      - /usr/local/docker/jupyterhub/home:/home
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DOCKER_NETWORK_NAME=jupyterhub_default
      - HUB_IP=jupyterhub

My jupyterhub_config.py file:

import os
c.JupyterHub.bind_url = 'http://0.0.0.0:8000'
c.JupyterHub.spawner_class = 'dockerspawner.DockerSpawner'
c.DockerSpawner.network_name = os.environ['DOCKER_NETWORK_NAME']
c.DockerSpawner.image = 'jupyter/tensorflow-notebook'
c.DockerSpawner.volumes = {'/usr/local/docker/jupyterhub/home/{username}/': '/home/jovyan/work', '/usr/local/docker/jupyterhub/data/config': '/etc/jupyter'}
c.JupyterHub.hub_bind_url = 'http://jupyterhub:8081'
c.Spawner.cpu_limit = 1
c.Spawner.mem_limit = '10G'
c.Spawner.cmd = ['jupyterhub-singleuser', '--allow-root']
c.JupyterHub.ssl_cert = '/srv/jupyterhub/xxx.crt'
c.JupyterHub.ssl_key = '/srv/jupyterhub/xxx.key'
c.Authenticator.admin_users = {'educationAdmin'}
c.JupyterHub.services = [
    {
        "name": "service-token",
        "admin": True,
        "api_token": "bb740514217440bda1d1c94881fa2dad",
    },
]
c.LocalAuthenticator.create_system_users = True
c.JupyterHub.tornado_settings = {
    'headers': {
        'Content-Security-Policy': "frame-ancestors 'self' https://xxx.com:7003 https://xxx.com http://localhost:8080"
    }
}
# c.Spawner.args = ['--NotebookApp.tornado_settings={'headers':{'Content-Security-Policy': 'frame-ancestors self https://xxx.com:7003 https://xxx.com http://localhost:8080',}}']
# c.JupyterHub.template_paths = ["/srv/jupyterhub/template"]

I don't know what else needs to be done, I just executeddocker-compose up and this error occurred. Please help me, thanks!

welcome[bot] commented 3 years ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

Mokyyds commented 3 years ago

The container keeps restarting after the error is reported image

manics commented 3 years ago

Hi! The jupyterhub/jupyterhub Docker image doesn't include DockerSpawner, you'll need to use a different image or build your own.

If you need more help please post on the Jupyter Community Forum. Thanks!

support[bot] commented 3 years ago

Hi there @BitPeaches :wave:!

I closed this issue because it was labelled as a support question.

Please help us organize discussion by posting this on the http://discourse.jupyter.org/ forum.

Our goal is to sustain a positive experience for both users and developers. We use GitHub issues for specific discussions related to changing a repository's content, and let the forum be where we can more generally help and inspire each other.

Thanks you for being an active member of our community! :heart:

Mokyyds commented 3 years ago

Hi! The jupyterhub/jupyterhub Docker image doesn't include DockerSpawner, you'll need to use a different image or build your own.

If you need more help please post on the Jupyter Community Forum. Thanks!

Thank you for your reply. Does the official image have "DockerSpawner"? I think the repository is also used "jupyterhub/jupyterhub", how do I need to install the customization? Is there a manual to help me build JupyterHub based on Docker. thanks