Skip to content

Instantly share code, notes, and snippets.

@zonca
Last active August 15, 2017 10:23
Show Gist options
  • Save zonca/83d222df8d0b9eaebd02b83faa676753 to your computer and use it in GitHub Desktop.
Save zonca/83d222df8d0b9eaebd02b83faa676753 to your computer and use it in GitHub Desktop.
Jupyterhub configuration for docker swarm
import os
# Point DockerSpawner to Swarm instead of the local DockerEngine
os.environ["DOCKER_HOST"] = ":4000"
# We use NGINX for SSL
c.JupyterHub.confirm_no_ssl = True
# The docker instances need access to the Hub, so the default loopback port doesn't work:
from IPython.utils.localinterfaces import public_ips
c.JupyterHub.hub_ip = public_ips()[0]
c.JupyterHub.spawner_class = 'dockerspawner.SystemUserSpawner'
# see https://hub.docker.com/r/zonca/jupyterhub-datascience-systemuser/builds/
c.DockerSpawner.container_image = 'zonca/jupyterhub-datascience-systemuser'
c.DockerSpawner.remove_containers = True
# The docker instances need access to the Hub, so the default loopback port
# doesn't work. We need to tell the hub to listen on 0.0.0.0 because it's in a
# container, and we'll expose the port properly when the container is run. Then,
# we explicitly tell the spawned containers to connect to the proper IP address.
c.JupyterHub.proxy_api_ip = '0.0.0.0'
c.DockerSpawner.container_ip = '0.0.0.0'
c.DockerSpawner.use_internal_ip = False
c.DockerSpawner.hub_ip_connect = c.JupyterHub.hub_ip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment