diff --git a/docker/Dockerfile b/docker/Dockerfile
index e3179b1e..56a98733 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -19,10 +19,11 @@ FROM debian:stable
# Labels for the docker image
LABEL maintainer="Pantelis Sopasakis
" \
- license="MIT license" \
- description="Jupyter notebook for Optimization Engine (OpEn)"
+ license="MIT license" \
+ description="Jupyter notebook for Optimization Engine (OpEn)"
WORKDIR /open
+VOLUME /open
# Example Python notebook
COPY example.ipynb /open/
@@ -32,28 +33,29 @@ ENV PATH="/root/.cargo/bin:${PATH}"
# These commands are groupped into a separate RUN to faciliate
# caching; it is unlikely that any of the following will change
# in future versions of this docker image
-RUN "sh" "-c" "echo nameserver 8.8.8.8 >> /etc/resolv.conf" \
- && apt-get update -y \
+RUN apt-get update -y \
&& apt-get -y --no-install-recommends install \
- build-essential \
- curl \
- jupyter-notebook \
- python3 \
- python3-pip \
- python3-setuptools \
- && curl https://sh.rustup.rs -sSf | bash -s -- -y \
- && pip3 install wheel \
- && pip3 install opengen \
- && apt-get clean \
- && rm -rf /var/lib/apt/lists/*
+ build-essential \
+ curl \
+ jupyter-notebook \
+ python3 \
+ python3-pip \
+ python3-setuptools \
+ python3-venv \
+ && curl https://sh.rustup.rs -sSf | bash -s -- -y \
+ && cd /; python3 -m venv venv \
+ && /bin/bash -c "source /venv/bin/activate && pip install wheel && pip install opengen && pip install jupyter" \
+ && apt-get clean \
+ && rm -rf /var/lib/apt/lists/* \
+ && echo "source /venv/bin/activate" >> /root/.bashrc
+EXPOSE 8888
# Run the following command every time this docker image
# is executed
COPY start_jupyter_notebook.sh /
RUN ["chmod", "+x", "/start_jupyter_notebook.sh"]
-ENTRYPOINT ["/start_jupyter_notebook.sh"]
-CMD ["/start_jupyter_notebook.sh"]
+CMD ["/bin/bash", "/start_jupyter_notebook.sh"]
@@ -64,4 +66,5 @@ CMD ["/start_jupyter_notebook.sh"]
#
# from within the base directory of this project.
#
+#
# ------------------------------------------------------------------------------
diff --git a/docker/README.md b/docker/README.md
index eaf02611..6c1def73 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -13,13 +13,57 @@ docker pull alphaville/open
and then run it with
```console
-docker run -p 8888:8888 -it alphaville/open
+docker run --name open-jupyter -p 8888:8888 -it alphaville/open
+```
+
+Note that this will create a docker container with name `open-jupyter`. If you stop it, you can restart it with (don't do `docker run` again)
+
+```console
+docker start -ai open-jupyter
```
## What it does
It starts a Jupyter Notebook at [localhost:8888](http://localhost:8888) without a password.
+## What's in the docker image?
+
+This docker image is build from `debian:stable` and contains:
+
+- A virtual environment (with Python 3)
+- Opengen [v0.8.0](https://github.com/alphaville/optimization-engine/releases/tag/opengen-0.8.0)
+- The [latest version](https://crates.io/crates/optimization_engine) of the OpEn rust solver is installed automatically
+- Jupyter notebook (runs automatically when the image runs)
+
+
+## How to open a terminal into the docker image
+
+Just
+
+```console
+docker exec -it open-jupyter bash
+```
+
+This will open a bash shell to the docker image with name `open-jupyter`; this is the name we specified above when we ran the image (using `--name open-jupyter`). In this bash shell, the virtual environment on which the Jupyter notebook is running is enabled by default.
+
+
+### How to run with specified volume
+
+Firstly, you need to create a volume. You only need to do this once (unless you want to create different volumes). As an example, let us create a docker volume with name `OpEnVolume`:
+
+```console
+docker volume create OpEnVolume
+```
+
+Next, let us run the image `alphaville/open:0.5.0` with the above volume:
+
+```console
+docker run --name open-jupyter \
+ --mount source=OpEnVolume,destination=/open \
+ -p 8888:8888 \
+ -it alphaville/open:0.5.0
+```
+
## Set a password
To set up a password for your Python Notebook:
@@ -33,7 +77,7 @@ docker run -e JUPYTER_NOTEBOOK_PASSWORD=... -p 8888:8888 -it alphaville/open
For example, let's say you want to set the password **open**. Then do
-```
+```console
docker run \
-e JUPYTER_NOTEBOOK_PASSWORD=sha1:898ca689bf37:2ee883bfd6ffe82a749a86e37964700bd06a2ff9 \
-p 8888:8888 -it alphaville/open
diff --git a/docker/start_jupyter_notebook.sh b/docker/start_jupyter_notebook.sh
index 4a2c6844..51604ac9 100644
--- a/docker/start_jupyter_notebook.sh
+++ b/docker/start_jupyter_notebook.sh
@@ -6,13 +6,13 @@ if [ -z "$JUPYTER_NOTEBOOK_PASSWORD" ]
then
echo "No Jupyter Notebook password provided - starting in unsafe mode"
echo "Set password using -e JUPYTER_NOTEBOOK_PASSWORD={sha of password}"
- jupyter notebook \
+ /venv/bin/jupyter notebook \
--port=8888 --no-browser \
--ip=0.0.0.0 --allow-root \
--NotebookApp.password='' --NotebookApp.token=''
else
echo "Jupyter Notebook password provided by user"
- jupyter notebook \
+ /venv/bin/jupyter notebook \
--port=8888 --no-browser \
--ip=0.0.0.0 --allow-root \
--NotebookApp.password=$JUPYTER_NOTEBOOK_PASSWORD