-
Notifications
You must be signed in to change notification settings - Fork 307
Open
Labels
Description
Bug description
Using {imagename} in name_template produces a Bad Request "Invalid container name" error when starting the server.
Expected behaviour
The container should spawn without error.
In addition, the container name should be based on the image, e.g., datascience-notebook for jupyter/datascience-notebook.
Actual behaviour
When launching the Jupyter notebook container, Jupyterhub sends this error:
Bad Request ("Invalid container name (jupyterhub-singleuser:3.1-vncntprvst–), only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed")
How to reproduce
Define c.DockerSpawner.name_template = '{imagename}-{username}–{servername}' in jupyterhub_config.py and
c.DockerSpawner.allowed_images = {
'Data science':'jupyter/datascience-notebook:latest'
}
then select 'Data science' from the drop-down menu
Your personal set up
The server code repository is found here: https://github.com/wanglab-neuro/jupyterlab_server
- OS: jupyterhub container
- Version(s):
jupyterhub/jupyterhub:3.1.1withdockerspawner 12.1.0
# JupyterHub configuration
import os, sys, pwd, subprocess, re
import docker
############################# Authentication ########################
### GitHub OAuth authentication
from oauthenticator.github import GitHubOAuthenticator
<...>
############################# Generic ########################
## Admin access: give admins permission to log in to the single user notebook servers owned by other users
c.JupyterHub.admin_access = True
############################# Permissions ########################
# Updating permissions for volumes mounted from host
c.DockerSpawner.extra_create_kwargs = {'user': 'root'}
c.DockerSpawner.environment = {
<...>
}
############################# Pre-spawn Hook ########################
def pre_spawn_hook(spawner):
<...>
c.Spawner.pre_spawn_hook = pre_spawn_hook
c.DockerSpawner.post_start_cmd = 'bash -c "/media/link_package_files.sh"'
############################# Docker Spawner Configuration ########################
c.JupyterHub.spawner_class = 'dockerspawner.DockerSpawner'
c.DockerSpawner.network_name = os.environ['DOCKER_NETWORK_NAME']
c.JupyterHub.hub_ip = os.environ['HUB_IP']
# Pick a docker image.
c.JupyterHub.allow_named_servers=True
c.DockerSpawner.name_template = '{imagename}-{username}–{servername}'
# c.DockerSpawner.name_template = '{imagename.split(":")[0]}-{username}--{servername}'
c.DockerSpawner.allowed_images = {
'Data science':'jupyter/datascience-notebook:latest'
}
## access GPU
c.DockerSpawner.extra_host_config = {
"device_requests": [
docker.types.DeviceRequest(
count=-1,
capabilities=[["gpu"]],
),
],
}
## Remove containers once they are stopped
c.DockerSpawner.remove = True
# User data persistence
home_dir = os.environ.get('DOCKER_NOTEBOOK_DIR') or '/home/jovyan' #os.path.join('/home', '{username}')
notebook_dir = home_dir # this is the root directory for the Jupyterlab sidebar
data_dir = home_dir + '/data'
c.DockerSpawner.notebook_dir = notebook_dir #home_dir
c.DockerSpawner.default_url = '/lab'
c.DockerSpawner.volumes = {
<...>
}
############################# Services ########################
c.JupyterHub.load_roles = [
{
"name": "jupyterhub-idle-culler-role",
"scopes": [
"list:users",
"read:users:activity",
"delete:servers",
# "admin:users", # if using --cull-users
],
# assignment of role's permissions to:
"services": ["jupyterhub-idle-culler-service"],
}
]
c.JupyterHub.services = [
{
"name": "jupyterhub-idle-culler-service",
"command": [
sys.executable,
"-m", "jupyterhub_idle_culler",
"--timeout=3600",
],
"admin": True, # Has to be disabled version>2.0
}
]