Commit b03bc335 authored by Florian de Boissieu's avatar Florian de Boissieu
Browse files

add a section in README for changing hub URL. Closes issue #1.

parent 45bdfab2
No related merge requests found
Showing with 79 additions and 1 deletion
+79 -1
......@@ -70,7 +70,33 @@ the `COMPOSE_PROJECT_NAME` that will serve as prefix to network name to separate
File `docker-compose.yml` contains:
```yaml
version: '3'
services:
# Configuration for Hub+Proxy
jupyterhub:
image: ${COMPOSE_PROJECT_NAME}_hub_img
build: jupyterhub # Build the container from this folder.
container_name: ${COMPOSE_PROJECT_NAME}_hub # The service will use this container name.
volumes: # Give access to Docker socket.
- /var/run/docker.sock:/var/run/docker.sock
- ./jupyterhub/jupyterhub_config.py:/srv/jupyterhub/jupyterhub_config.py
environment: # Env variables passed to the Hub process.
DOCKER_JUPYTER_IMAGE: jupyter/minimal-notebook
DOCKER_NETWORK_NAME: ${COMPOSE_PROJECT_NAME}_default
HUB_IP: ${COMPOSE_PROJECT_NAME}_hub
ports:
- "8000:8000"
# Configuration for the single-user servers
jupyterlab:
image: jupyter/minimal-notebook
network_mode: none
command: echo
networks:
default:
name: ${COMPOSE_PROJECT_NAME}_default
```
### Build and run
......@@ -95,6 +121,57 @@ The following code should remove jupyterhub and user containers respectively.
docker-compose down && docker rm $(docker ps -qa -f "name=jupyter-")
```
### Change hub URL
The the hub URL can be changed with `bind_url`. Example, if I want to route the hub to http://localhost/minimal_notebook
instead of http://localhost:8000 I could do the following:
```yaml
# File docker-compose.yml
version: '3'
services:
# Configuration for Hub+Proxy
jupyterhub:
image: ${COMPOSE_PROJECT_NAME}_hub_img
build: jupyterhub # Build the container from this folder.
container_name: ${COMPOSE_PROJECT_NAME}_hub # The service will use this container name.
volumes: # Give access to Docker socket.
- /var/run/docker.sock:/var/run/docker.sock
- ./jupyterhub/jupyterhub_config.py:/srv/jupyterhub/jupyterhub_config.py
environment: # Env variables passed to the Hub process.
DOCKER_JUPYTER_IMAGE: jupyter/minimal-notebook
DOCKER_NETWORK_NAME: ${COMPOSE_PROJECT_NAME}_default
HUB_IP: ${COMPOSE_PROJECT_NAME}_hub
COMPOSE_PROJECT_NAME: ${COMPOSE_PROJECT_NAME}
ports:
- "80:80"
# Configuration for the single-user servers
jupyterlab:
image: jupyter/minimal-notebook
network_mode: none
command: echo
networks:
default:
name: ${COMPOSE_PROJECT_NAME}_default
```
```python
# jupyterhub_config.yml
c = get_config()
import os
c.JupyterHub.spawner_class = 'dockerspawner.DockerSpawner'
c.DockerSpawner.image = os.environ['DOCKER_JUPYTER_IMAGE']
c.DockerSpawner.network_name = os.environ['DOCKER_NETWORK_NAME']
c.JupyterHub.hub_ip = os.environ['HUB_IP']
c.JupyterHub.bind_url = 'http://0.0.0.0:80/'+os.environ['COMPOSE_PROJECT_NAME']
```
However, with the docker port binding `80:80`, it wouldn't be possible to run another hub in parallel (e.g. for another tutorial).
Thus rerouting outside the container would be a better solution (to be documented).
## Rstudio
An Rstudio-session can be launched from inside a jupyterlab session with
......@@ -145,6 +222,7 @@ These variables are stored in .env file and called in jupyterhub_config.py.
# Authors
Florian de Boissieu
Rémy Decoupes
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment