Access to outside world from a DockerSpawner spawned container

Hi

I’ve been trying to weave together a Django based service which among other things provides an OAuth mechanism to authenticate users for access to JupyterHub.

It is critical for my use case that the spawned container have access to the outside world. But for some reason I am unable to get these spawned notebook containers to access the world outside.

A more detailed description is here : https://github.com/jupyterhub/dockerspawner/issues/355

Any hint or help would be greatly appreciated. Thanks so much.

Hi!

So I was able to find the solution. I summarize it below.

Adjustments to docker-compose.yml include adding a network_mode: bridge to all the services. This allows the containers to essentially access the outside world. The cost of doing so however is that the containers cannot automatically talk to each other via simple service name reference. But this can easily be solved using links.

The next adjustment was to configure the DockerSpawner to create containers that use the default bridge network instead of some other network. The settings that help with this include:

c.DockerSpawner.network_name = 'bridge'
c.DockerSpawner.use_internal_ip = True
c.DockerSpawner.extra_host_config = {'network_mode': 'bridge'}

Also, since it is not possible for the notebook to discover the main JupyterHub using service name, I adjust the c.JupyterHub.hub_connect_ip to the hostname of the JupyterHub service. Note that the use of a dns-proxy-server mentioned in my question helps resolve the hostname to the container IP.

Hope this helps someone out there. I will be posting the whole Django-OAuth-JupyterHub example soon on my blog.