| id | docker |
|---|---|
| title | Docker |
| sidebar_label | Docker |
| description | Docker image of a JupyterLab environment to run OpEn |
Docker is a tool for packaging applications and their dependencies into containers. A container can run on different machines without requiring you to recreate the same environment manually.
According to jupyter.org, JupyterLab is a web-based development environment for notebooks, code, and data.
You need to have Docker installed. See the official installation instructions.
You can download the current Docker image using:
docker pull alphaville/open:0.6.0and then run it with:
docker run --name open-jupyter -p 127.0.0.1:8888:8888 -it alphaville/open:0.6.0This starts JupyterLab and makes it available at:
The image currently includes:
- Python 3.12
opengen==0.10.0- JupyterLab
- Rust installed through
rustup - Example notebooks under
/open/notebooks
By default, JupyterLab starts with token authentication enabled. To view the token:
docker logs open-jupyterIt is always a good idea to give your container a name using --name.
docker run only the first time you create the container. Use docker start -ai open-jupyter to start it again later.docker stop open-jupyter.To run JupyterLab with a password instead of the default token, provide a hashed password through JUPYTER_NOTEBOOK_PASSWORD:
docker run \
--name open-jupyter \
-e JUPYTER_NOTEBOOK_PASSWORD='your hashed password' \
-p 127.0.0.1:8888:8888 \
-it alphaville/open:0.6.0For password hashing instructions, see the Jupyter Server documentation.
How to set up a password
You can read more about how to set up a password for your Python notebook here. TL;DR: run the following command:
docker run --rm -it --entrypoint /venv/bin/python \
alphaville/open:0.6.0 \
-c "from jupyter_server.auth import passwd; print(passwd())"You will be asked to provide your password twice. Then a string will be printed; this is your hashed password.
You can access JupyterLab on a different host port by changing Docker's port forwarding. For example, to use port 80 on your machine:
docker run -p 80:8888 alphaville/open:0.6.0Then JupyterLab will be available at http://localhost/lab.
The bundled example notebook is available inside the container at:
/open/notebooks/example.ipynb
To persist your own notebooks across container restarts, mount a Docker volume onto /open:
docker volume create OpEnVolume
docker run --name open-jupyter \
--mount source=OpEnVolume,destination=/open \
-p 127.0.0.1:8888:8888 \
-it alphaville/open:0.6.0You can install additional packages from inside JupyterLab. For example:
!pip install matplotlibPackages installed into a persistent container or volume-backed environment will still be there the next time you access it.
Suppose you have a running Docker container with name open-jupyter. To open a shell in it:
docker exec -it open-jupyter /bin/bashThe Python virtual environment is available at /venv.
To download a generated optimizer from JupyterLab, first create an archive:
!tar -cf rosenbrock.tar.gz optimizers/rosenbrock