Ip error while trying to add volume

Hi, I have a problem, becouse I used this example config and it worked fine, but when I started to do something with volumes, I got error:

Unhandled error starting d746c770-7eee-40fa-b073-97fe3a578569’s server: The ‘ip’ trait of a Server instance must be a unicode string, but a value of None <class ‘NoneType’> was specified.

All I changed was jupyterhub_config.py - I added volumes and changed authenticator, but that’s all:

import os

c.JupyterHub.authenticator_class = "tmpauthenticator.TmpAuthenticator"

# launch with docker
c.JupyterHub.spawner_class = 'dockerspawner.DockerSpawner'

# we need the hub to listen on all ips when it is in a container
c.JupyterHub.hub_ip = ''
# the hostname/ip that should be used to connect to the hub
# this is usually the hub container's name
c.JupyterHub.hub_connect_ip = 'jupyterhub'

# pick a docker image. This should have the same version of jupyterhub
# in it as our Hub.
c.DockerSpawner.image = 'jupyter/scipy-notebook'

# tell the user containers to connect to our docker network
c.DockerSpawner.network_name = 'jupyterhub'

# delete containers when the stop
c.DockerSpawner.remove = True

c.DockerSpawner.volumes = {'/volumes/jupyterhub/{username}/': '/home/jovyan/work'}

def create_dir_hook(spawner):
    """ Create directory """
    username = spawner.user.name  # get the username
    volume_path = os.path.join('/volumes/jupyterhub', username)
    if not os.path.exists(volume_path):
        os.makedirs(volume_path, mode=0o755, exist_ok = True)
    filepath = os.path.join(volume_path, 'file.txt')
    with open(filepath, 'w') as fp: 

c.Spawner.pre_spawn_hook = create_dir_hook

I saw other topics with this error, but none with solution, so I would be very glad for one :slight_smile:

I never got volumes to work, I ended up using bind mounts. Maybe this can help you: https://github.com/jupyterhub/dockerspawner/issues/248


Nice to know … I’m sitting on this for a week and still nothing :unamused: Thanks a lot, at least I will try something new, maybe this will work