Max
Max

Reputation: 560

Adding additional host to Juypterhub DockerSpawner

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

Upvotes: 5

Views: 693

Answers (1)

Vanilla_Brys
Vanilla_Brys

Reputation: 63

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.

Upvotes: 5

Related Questions