Docker images with NEST, NEURON, Brian and PyNN

249 views
Skip to first unread message

Andrew Davison

unread,
Aug 28, 2015, 11:11:36 AM8/28/15
to Neural Ensemble
Dear all,

I have created a couple of Docker images, based on Neurodebian (Jessie), which provide pre-built environments for neural simulation with Python, including NEST 2.6.0, NEURON 7.3, Brian 1.4 and PyNN 0.8.0rc1.

More details in the following blog post:


(For those not familiar with Docker, it is a tool based on LXC (Linux containers), which provides a more lightweight alternative to VMs).

Best regards,

Andrew

ap...@nu.edu.kz

unread,
Nov 16, 2016, 11:33:35 PM11/16/16
to Neural Ensemble
Hello,

I am new to neural simulations and wanted to try docker image with pre installed neural simulators. I installed docker (stable channel, which runs natively on Mac OS) and then downloaded the docker image:py2. It seems to work but I was wondering whether I can use it in jupyter notebook. It is not really convenient to use in terminal (I am not sure how people generally use it). 

So I installed jupyter (pip) but it did not work. 

(neurosci)docker@c41bba35e30e:~$ jupyter notebook

[I 04:01:08.944 NotebookApp] Writing notebook server cookie secret to /home/docker/.local/share/jupyter/runtime/notebook_cookie_secret

[I 04:01:08.970 NotebookApp] Serving notebooks from local directory: /home/docker

[I 04:01:08.970 NotebookApp] 0 active kernels 

[I 04:01:08.970 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/

[I 04:01:08.970 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

[W 04:01:08.971 NotebookApp] No web browser found: could not locate runnable browser.



I also tried

docker run -p 8888:8888 -i -t neuralensemble/simulation:py2 /bin/bash


but still did not work.

I would appreciate any suggestion on how to make it work.

Also, is it a normal behaviour that after typing docker run -i -t neuralensemble/simulation:py2 /bin/bash
environment is activated? I thought the container should be activated and only after source ~/env/neurosci/bin/activate 
the neurosci env should be activated.

Thanks for developing such a nice env,

Andrew Davison

unread,
Nov 17, 2016, 12:15:11 PM11/17/16
to Neural Ensemble
On Thursday, 17 November 2016 05:33:35 UTC+1, ap...@nu.edu.kz wrote:
Hello,

I am new to neural simulations and wanted to try docker image with pre installed neural simulators. I installed docker (stable channel, which runs natively on Mac OS) and then downloaded the docker image:py2. It seems to work but I was wondering whether I can use it in jupyter notebook. It is not really convenient to use in terminal (I am not sure how people generally use it). 

I usually use the neuralensemble/simulationx image (note the extra "x"), which runs as a server, allowing you to have multiple ssh connections and use X-windows applications.
 

So I installed jupyter (pip) but it did not work. 

(neurosci)docker@c41bba35e30e:~$ jupyter notebook

[I 04:01:08.944 NotebookApp] Writing notebook server cookie secret to /home/docker/.local/share/jupyter/runtime/notebook_cookie_secret

[I 04:01:08.970 NotebookApp] Serving notebooks from local directory: /home/docker

[I 04:01:08.970 NotebookApp] 0 active kernels 

[I 04:01:08.970 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/

[I 04:01:08.970 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

[W 04:01:08.971 NotebookApp] No web browser found: could not locate runnable browser.



I also tried

docker run -p 8888:8888 -i -t neuralensemble/simulation:py2 /bin/bash


but still did not work.

I would appreciate any suggestion on how to make it work.


To solve this, I created a new Dockerfile containing the following:

FROM neuralensemble/simulation:py2

USER docker
RUN /home/docker/env/neurosci/bin/pip install jupyter

USER root

ENV TINI_VERSION v0.6.0
RUN chmod +x /usr/bin/tini
ENTRYPOINT ["/usr/bin/tini", "--"]

EXPOSE 8888
CMD ["/home/docker/env/neurosci/bin/jupyter", "notebook", "--port=8888", "--no-browser", "--ip=0.0.0.0"]
 
I then ran:

docker build -t neuraljupyter .
docker run -d  -p 8888:8888 neuraljupyter


Also, is it a normal behaviour that after typing docker run -i -t neuralensemble/simulation:py2 /bin/bash
environment is activated? I thought the container should be activated and only after source ~/env/neurosci/bin/activate 
the neurosci env should be activated.

.bashrc activates the virtualenv
 

Thanks for developing such a nice env,

You're welcome! 


Andrew

ap...@nu.edu.kz

unread,
Nov 18, 2016, 1:13:22 AM11/18/16
to Neural Ensemble
Thanks for a quick reply, I tried your code but it sent a really huge context so I stopped it. How should I change the code to build from any folder (not root)?

Also, as I understood you are proposing to use jupyter as cmd (is that correct?) but I just wanted to use jupyter to run python.

Anyway, I had some time today to look into it and this seems to work:

docker run -p 8888:8888 -i -t neuralensemble/simulation:py2 /bin/bash

pip install --upgrade pip

pip install jupyter

jupyter notebook --ip 0.0.0.0 --no-browser


The only problem is that when I exit container all changes are gone (need to install everything again). Is there is a way to change the container permanently (add jupyter) without re building image, will commit changes work for this? 

I am new to docker, so sorry for asking trivial questions.

From docker:
Warning
: Do not use your root directory, /, as the PATH as it causes the build to transfer the entire contents of your hard drive to the Docker daemon.

Andrew Davison

unread,
Nov 18, 2016, 9:11:39 AM11/18/16
to Neural Ensemble

On Friday, 18 November 2016 07:13:22 UTC+1, ap...@nu.edu.kz wrote:
Thanks for a quick reply, I tried your code but it sent a really huge context so I stopped it. How should I change the code to build from any folder (not root)?

The code will build in any folder. I ran "docker build" and "docker run" in a subdirectory containing some Jupyter notebooks.
 
Also, as I understood you are proposing to use jupyter as cmd (is that correct?) but I just wanted to use jupyter to run python.

When you launch a container with Docker, it launches Jupyter notebook automatically.
 

The only problem is that when I exit container all changes are gone (need to install everything again). Is there is a way to change the container permanently (add jupyter) without re building image, will commit changes work for this? 

Yes, read about "docker commit"
 

ap...@nu.edu.kz

unread,
Nov 18, 2016, 8:39:54 PM11/18/16
to Neural Ensemble
Thanks, it worked!
Reply all
Reply to author
Forward
0 new messages