add self container start notebook
This commit is contained in:
62
docker-compose-self.yml
Executable file
62
docker-compose-self.yml
Executable file
@@ -0,0 +1,62 @@
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
# JupyterHub docker compose configuration file
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
hub:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.jupyterhub
|
||||
args:
|
||||
JUPYTERHUB_VERSION: latest
|
||||
restart: always
|
||||
image: quay.io/hotwa/jupyterhub:latest
|
||||
container_name: jupyterhub
|
||||
networks:
|
||||
- jupyterhub-network
|
||||
volumes:
|
||||
# The JupyterHub configuration file
|
||||
- "./jupyterhub_config_self.py:/srv/jupyterhub/jupyterhub_config.py:ro"
|
||||
# Bind Docker socket on the host so we can connect to the daemon from
|
||||
# within the container
|
||||
- "/var/run/docker.sock:/var/run/docker.sock:rw"
|
||||
# Bind Docker volume on host for JupyterHub database and cookie secrets
|
||||
- "./jupyterhub-data:/data"
|
||||
ports:
|
||||
- "8000:8000"
|
||||
- "8080:8080"
|
||||
environment:
|
||||
# This username will be a JupyterHub admin
|
||||
JUPYTERHUB_ADMIN: admin
|
||||
# All containers will join this network
|
||||
DOCKER_NETWORK_NAME: jupyterhub-network
|
||||
# JupyterHub will spawn this Notebook image for users
|
||||
DOCKER_NOTEBOOK_IMAGE: quay.io/hotwa/notebook:latest
|
||||
# Notebook directory inside user image
|
||||
DOCKER_NOTEBOOK_DIR: /home/jovyan/work
|
||||
|
||||
nginx:
|
||||
image: nginx:latest
|
||||
container_name: nginx-proxy
|
||||
depends_on:
|
||||
- hub
|
||||
volumes:
|
||||
- "./nginx.conf:/etc/nginx/nginx.conf:ro"
|
||||
- "./nginx-selfsigned.crt:/etc/ssl/certs/nginx-selfsigned.crt:ro"
|
||||
- "./nginx-selfsigned.key:/etc/ssl/private/nginx-selfsigned.key:ro"
|
||||
- "./dhparam.pem:/etc/ssl/certs/dhparam.pem:ro"
|
||||
ports:
|
||||
- "50000:443"
|
||||
networks:
|
||||
- jupyterhub-network
|
||||
|
||||
volumes:
|
||||
jupyterhub-data:
|
||||
|
||||
networks:
|
||||
jupyterhub-network:
|
||||
name: jupyterhub-network
|
||||
|
||||
# use 127.0.0.1:8000 access
|
||||
48
jupyterhub_config_self.py
Executable file
48
jupyterhub_config_self.py
Executable file
@@ -0,0 +1,48 @@
|
||||
import os
|
||||
|
||||
c = get_config() # noqa: F821
|
||||
|
||||
# 基本配置
|
||||
c.Authenticator.allow_all = True
|
||||
c.JupyterHub.spawner_class = "jupyterhub.spawner.LocalProcessSpawner"
|
||||
|
||||
# 单用户配置
|
||||
c.Spawner.cmd = ['jupyter-labhub']
|
||||
c.Spawner.default_url = '/lab'
|
||||
c.Spawner.notebook_dir = '/home/jovyan'
|
||||
c.Spawner.environment = {
|
||||
'JUPYTER_ENABLE_LAB': 'yes',
|
||||
'NOTEBOOK_ARGS': '--NotebookApp.allow_origin="*" --NotebookApp.iopub_data_rate_limit=10000000',
|
||||
}
|
||||
|
||||
# Hub IP 和端口配置
|
||||
c.JupyterHub.hub_ip = '0.0.0.0'
|
||||
c.JupyterHub.hub_port = 8080
|
||||
|
||||
# Cookie secret 和数据库 URL
|
||||
c.JupyterHub.cookie_secret_file = '/srv/jupyterhub/jupyterhub_cookie_secret'
|
||||
c.JupyterHub.db_url = 'sqlite:////srv/jupyterhub/jupyterhub.sqlite'
|
||||
|
||||
# Authenticator 配置
|
||||
c.JupyterHub.authenticator_class = 'nativeauthenticator.NativeAuthenticator'
|
||||
c.NativeAuthenticator.open_signup = True
|
||||
|
||||
# 管理员配置
|
||||
admin = os.environ.get('JUPYTERHUB_ADMIN')
|
||||
if admin:
|
||||
c.Authenticator.admin_users = {admin}
|
||||
|
||||
# 调试模式
|
||||
c.JupyterHub.log_level = 'DEBUG'
|
||||
c.Spawner.debug = True
|
||||
|
||||
# GPU 和网络配置(仅在需要 GPU 时启用)
|
||||
c.Spawner.environment.update({
|
||||
'NVIDIA_DRIVER_CAPABILITIES': 'compute,utility',
|
||||
'NVIDIA_VISIBLE_DEVICES': 'all'
|
||||
})
|
||||
|
||||
# 可选:GPU runtime 配置
|
||||
c.Spawner.extra_host_config = {
|
||||
'runtime': 'nvidia'
|
||||
}
|
||||
Reference in New Issue
Block a user