Deploy Jupyter Lab in an Anaconda container with docker compose

Compose YML

1
2
3
4
5
6
7
8
9
10
version: "3.3"
services:
anaconda:
image: continuumio/anaconda3
container_name: anaconda
volumes:
- ./notebooks:/opt/notebooks
ports:
- 16000:8888
command: bash -c "conda install jupyterlab -y --quiet && mkdir -p /opt/notebooks && jupyter lab --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser --allow-root"

In docker-compose file, we need to use bash -c to run multi commands.

Setting password for JupyterLab

We can use token to change password for jupyterlab on first login, then restart server.

Edit kernel in JupyterLab

## Step 1 activate target environment ## Step 2 install ipykernel conda install ipykernel ## Step 3 set up kernel add kernel into jupyterlab python -m ipykernel install --name [kernel name] ## Step 4 exsisting kernel jupyter kernelspec list ## Step 5 remove kernel jupyter kernelspec remove [kernel name]

Important

The communication to the kernel goes through WebSockets, which means you need to support WebSockets when using Nginx!