5

I am using Jupyterhub 0.9.4 with DockerSpawner. My goal is to pass every container spawned by the Spawner an additional host name, so make an additional entry in /etc/hosts.

I first tried via my docker-compose.yml file, which does not work, as the container are created by Jupyterhub.

I also tried it in the Dockerfile itself, but there it got overwritten.

I further tried it with changes in the jupyterhub_config.py file, by adding: c.DockerSpawner.extra_create_kwargs.update({'command': '--add-host="<ip-address> <hostname>"'})

Still I do not see an entry in the /etc/hosts file in the container.

Anyone has a clue where I have to add it?

Thanks, Max

Max
  • 560
  • 1
  • 9
  • 25

1 Answers1

5

You can do the equivalent of docker run --add-host "foo.domain.local:192.168.1.12" ... like so:

c.DockerSpawner.extra_host_config.update({
  "extra_hosts": {
    "foo.domain.local":"192.168.1.12",
    "other.domain.local":"192.168.1.13"
  }
})

I couldn't find that in any documentation.

Vanilla_Brys
  • 63
  • 1
  • 5