How to use the dockerspawner.volumenamingstrategy.escaped_format_volume_name function in dockerspawner

To help you get started, we’ve selected a few dockerspawner examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HarryKodden / JupyterHub-SAML / etc / jupyterhub / jupyterhub_config.py View on Github external
#c.JupyterHub.ssl_cert = os.environ['SSL_CERT']
#c.JupyterHub.ssl_key = os.environ['SSL_KEY']
c.JupyterHub.confirm_no_ssl = True

c.JupyterHub.spawner_class = 'dockerspawner.DockerSpawner'
# JupyterHub requires a single-user instance of the Notebook server, so we
# default to using the `start-singleuser.sh` script included in the
# jupyter/docker-stacks *-notebook images as the Docker run command when
# spawning containers.  Optionally, you can override the Docker run command
#network_name = os.environ.get('DOCKER_NETWORK_NAME')
network_name = 'jupyterhubsaml_back-end'
c.DockerSpawner.use_internal_ip = True
c.DockerSpawner.network_name = network_name

import dockerspawner
c.DockerSpawner.format_volume_name = dockerspawner.volumenamingstrategy.escaped_format_volume_name
# Pass the network name as argument to spawned containers
c.DockerSpawner.extra_host_config = { 'network_mode': network_name }
#c.DockerSpawner.extra_start_kwargs = { 'network_mode': network_name }
# Explicitly set notebook directory because we'll be mounting a host volume to
# it.  Most jupyter/docker-stacks *-notebook images run the Notebook server as
# user `jovyan`, and set the notebook directory to `/home/jovyan/work`.
# We follow the same convention.
notebook_dir = '/home/jovyan/work'
c.DockerSpawner.notebook_dir = notebook_dir
# Mount the real user's Docker volume on the host to the notebook user's
# notebook directory in the container
c.DockerSpawner.volumes = { 'jupyterhub-user-{username}': notebook_dir }
c.DockerSpawner.extra_create_kwargs.update({ 'volume_driver': 'local' })
# Remove containers once they are stopped
c.DockerSpawner.remove_containers = True
# For debugging arguments passed to spawned containers