I was trying to configure a docker environment where one of my services would be a jupyterhub with pre-customised images. I am using traefik as a reverse proxy because when deploying I will use a domain instead of localhost. Here are my docker-composer and jupyterhub_config.py
version: “3.8”
services:
traefik:
image: traefik:v3.0
command:
- “–api.insecure=true”
- “–entrypoints.websecure.address=:443”
- “–providers.docker=true”
- “–providers.file.filename=/etc/traefik_dynamic.yml”
- “–providers.file.watch=true”
ports:
- “443:443”
- “8888:8888”
volumes:
- “/var/run/docker.sock:/var/run/docker.sock”
- “./certs:/certs”
- “./traefik_dynamic.yml:/etc/traefik_dynamic.yml”
networks:
- lepocolab-net
labels:
- “traefik.enable=true”lepocolab:
build: ./build/lepocolab
image: lepocolab/hub
container_name: lepocolab
environment:
- CONFIGPROXY_AUTH_TOKEN=dummytoken
volumes:
- ./conf:/srv/jupyterhub
- ./shared:/home/jovyan/shared
- /var/run/docker.sock:/var/run/docker.sock
restart: always
labels:
- “traefik.enable=true”
- “traefik.http.routers.jupyterhub.rule=Host(localhost
) && PathPrefix(/colab
)”
- “traefik.http.routers.jupyterhub.entrypoints=websecure”
- “traefik.http.routers.jupyterhub.tls=true”
- “traefik.http.services.jupyterhub.loadbalancer.server.port=8888”
networks:
- lepocolab-netnetworks:
lepocolab-net:
driver: bridge---------------------------
CONFIGURAÇÃO GERAL DO JUPYTERHUB
---------------------------
c.JupyterHub.bind_url = “http://0.0.0.0:8888/colab”
c.JupyterHub.cleanup_servers = False
c.JupyterHub.proxy_api_url = “https://localhost/colab/hub/api”
c.JupyterHub.proxy_auth_token = os.environ[‘CONFIGPROXY_AUTH_TOKEN’]
c.DockerSpawner.network_name = ‘lepocolab_lepocolab-net’ # nome da rede Docker---------------------------
AUTENTICAÇÃO
---------------------------
c.JupyterHub.authenticator_class = “dummy”
c.DummyAuthenticator.password = “123”---------------------------
DOCKERSPAWNER
---------------------------
c.JupyterHub.spawner_class = “dockerspawner.DockerSpawner”
c.DockerSpawner.allowed_images = [
‘lepocolab/datascience-notebook:ubuntu-24.04’,
‘lepocolab/pytorch-notebook:ubuntu-24.04’,
‘lepocolab/tensorflow-notebook:ubuntu-24.04’,
]c.DockerSpawner.http_timeout = 300 # Aumentar o tempo de espera para 60 segundos
c.JupyterHub.log_level = ‘DEBUG’
c.DockerSpawner.volumes = {
‘/home/user/jupyterhub/users/{username}/work’: ‘/home/{username}/work’,
}c.JupyterHubSingleUser.check_hub_version = False
c.DockerSpawner.api_url = None # Impede a comunicação com a API do Hubc.DockerSpawner.port = 8000
c.DockerSpawner.remove = True
c.DockerSpawner.extra_create_kwargs = {
‘user’: ‘root’
}
c.DockerSpawner.extra_host_config = {
‘mem_limit’: ‘1G’,
‘memswap_limit’: ‘1G’
}---------------------------
SERVIÇO DE LIMPEZA
---------------------------
c.JupyterHub.services = [
{
‘name’: ‘idle-culler’,
‘admin’: True,
‘command’: [
sys.executable,
‘-m’, ‘jupyterhub_idle_culler’,
‘–timeout=604800’,
],
},
]