# Workflow with Docker and Slicer

**URL:** https://discourse.slicer.org/t/workflow-with-docker-and-slicer/4091
**Category:** Support
**Created:** [September 12, 2018, 7:22pm UTC](https://discourse.slicer.org/t/workflow-with-docker-and-slicer/4091 "2018-09-12T19:22:56Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![darekdev](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@darekdev](https://discourse.slicer.org/u/darekdev)
#### Post date: [September 12, 2018, 7:22pm UTC](https://discourse.slicer.org/t/workflow-with-docker-and-slicer/4091/1 "2018-09-12T19:22:56Z")

</div>

Hi,

I’am a scientist and working with Slicer build inside a docker image but I want make some upgrade in a workflow and add SlicerJupyter extension. I have a dream that I am preparing a docker image for my friends in team. In last few days I did some research about your solution with docker but I got lost in this topic. What need I to create a dream workflow:

- Create docker image with build version Slicer Qt5 (always need builded version because I working with own extensions
- Build and install to Slicer SlicerJupyter extension(this will allow me to accelerate my work considerably and simply - JUPYTER is awesome)
- Redistribute created image.  
Now I have only working version with Slicer Qt4 but for this version I can’t build SlicerJupyter.

Have you got some suggestion how I can improve that workflow? What image (for example from [https://github.com/thewtex/SlicerDocker](https://github.com/thewtex/SlicerDocker)) should I use? And what do if my computer has Nvidia and other ATI or Intel graphic cards? Should I install all drivers?

Regards,  
Darek

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [September 17, 2018, 2:21pm UTC](https://discourse.slicer.org/t/workflow-with-docker-and-slicer/4091/2 "2018-09-17T14:21:23Z")

</div>

Hi Darek -

You can have a look at my dockerfiles. It should be no problem to get a latest nightly build and install the jupyter extension in a dockerfile. Then you can push the result back to dockerhub or other repository.

> **[GitHub - pieper/SlicerDockers: docker config files for slicer](https://github.com/pieper/SlicerDockers)**
>
> docker config files for slicer. Contribute to pieper/SlicerDockers development by creating an account on GitHub.

This will provide a software rendering layer with vnc access for the browser (not GPU accelerated but still typically quite usable).

---

<div class="post-metadata">

### Author: ![darekdev](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@darekdev](https://discourse.slicer.org/u/darekdev)
#### Post date: [September 17, 2018, 8:22pm UTC](https://discourse.slicer.org/t/workflow-with-docker-and-slicer/4091/3 "2018-09-17T20:22:23Z")

</div>

Thank you for your reply. I have got your solution before and additionaly I have installed X11 and nvidia drivers inside. Then connect to container with volume /tmp/X11 and share $DISPLAY. Works great but now I have simplier solution as I think:  
I get out from docker packed Slicer nightly build and packed SlicerJupyter and working on this. Then I have gave a chance for [https://github.com/Slicer/SlicerBuildEnvironment:](https://github.com/Slicer/SlicerBuildEnvironment:) build Slicer and SlicerJupyter but with this envoronment I dont know why Slicer (when I connect to SlicerJupyter) has 100% CPU usage.  
Well now I have working nightly Slicer from pieper/SlicerDockers extracted and I build my extension through SlicerBuildEnvironment and copy libs.

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [September 17, 2018, 9:32pm UTC](https://discourse.slicer.org/t/workflow-with-docker-and-slicer/4091/4 "2018-09-17T21:32:05Z")

</div>

Sounds great - if you have any examples of installing nvidia drivers or running jupyter through Slicer in docker please post.

---

<div class="post-metadata">

### Author: ![darekdev](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@darekdev](https://discourse.slicer.org/u/darekdev)
#### Post date: [September 18, 2018, 1:02pm UTC](https://discourse.slicer.org/t/workflow-with-docker-and-slicer/4091/5 "2018-09-18T13:02:07Z")

</div>

I have been working with Docker and Slicer around 2 years and I installed packages in the docker by trial and error (I have never successfully compile Qt 4 and 5). Probably it’s nothing revealing:

- I use Ubuntu 16.04 image(with 18 I have compile errors),
- Download prebuilt qt unified version,
- Install dependencies etc [Documentation/Nightly/Developers/Build Instructions - Slicer Wiki](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Build_Instructions), after successfully building process I test Slicer on my laptop with GTX 980m and of course in docker I have got errors. Simple solution:
- Install nvidia drivers but carefully. I have on my host a nvidia-396 drivers and the same drivers must be installed in docker(now Slicer is running),
- Install dependencies for SlicerJupyter:

> ```
> sudo apt-get install libicu-dev
> sudo apt-get install uuid-dev
> 
> ```

- Build SlicerJupyter based on previously built Slicer,
- Create conda environment and connect Slicer with Jupyter.  
I run docker with this script:

> #!/bin/bash  
> xhost +local:docker  
> PATH\_TO\_EHDD=$1  
> docker run\  
> –privileged\  
> -v $PATH\_TO\_EHDD/software:/home/software:rw\  
> -v /dev:/dev/:ro\  
> -e QT\_X11\_NO\_MITSHM=1\  
> -e DISPLAY=$DISPLAY\  
> -v /tmp/.X11-unix/:/tmp/.X11-unix:ro\  
> –user broncho\  
> -it slicer\_jupyter:nv /bin/bash

Explanation of some parameters:  
-v /dev/:/dev/  
I need this volume because I use sensors on /dev/ttyACM\*

-e DISPLAY=$DISPLAY\  
-v /tmp/.X11-unix/:/tmp/.X11-unix:ro\  
It allows me to run GUI programs like Slicer

Now as I said before I packed Slicer and SlicerJupyter and working with it outside the docker on the host. JupyterLab is my current IDE.  
Remember that when you are move Slicer executables(for example working on a packaged version) you need to change paths in this two files: **kernel.json** and **AdditionalLauncherSettings.ini**

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [September 18, 2018, 8:38pm UTC](https://discourse.slicer.org/t/workflow-with-docker-and-slicer/4091/6 "2018-09-18T20:38:45Z")

</div>

It is great that you find Slicer and SlicerJupyter useful. Thanks for sharing information about how your setup works.

> [@darekdev](#):
>
> Remember that when you are move Slicer executables(for example working on a packaged version) you need to change paths in this two files: **kernel.json** and **AdditionalLauncherSettings.ini**

Note that Slicer can install when you click “Install Slicer kernel in Jupyter” then it updates the path in the kernel file and installs it. [I’ve updated JupyterKernel module](https://github.com/Slicer/SlicerJupyter/commit/ed8aa847fcae51be98278a8d1a4e2690099449a6) to make this feature available from Python (so that you can automate it as part of the installation process).

If you package the extension and install the extension from file it using the extension manager (by calling `slicer.app.extensionsManagerModel().installExtension()`) then you don’t need additional launcher settings, because all the libraries are installed into standard locations where Slicer can find them automatically.

> [@darekdev](#):
>
> with this envoronment I dont know why Slicer (when I connect to SlicerJupyter) has 100% CPU usage

See this issue: [JupyterKernel uses 100% CPU when idle · Issue #16 · Slicer/SlicerJupyter · GitHub](https://github.com/Slicer/SlicerJupyter/issues/16)  
It would be nice if you could give it a try to solve this problem.

---

<div class="post-metadata">

### Author: ![darekdev](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@darekdev](https://discourse.slicer.org/u/darekdev)
#### Post date: [September 18, 2018, 9:54pm UTC](https://discourse.slicer.org/t/workflow-with-docker-and-slicer/4091/7 "2018-09-18T21:54:56Z")

</div>

Hi Andras,

> [@lassoan](#):
>
> Note that Slicer can install when you click “Install Slicer kernel in Jupyter” then it updates the path in the kernel file and installs it. [I’ve updated JupyterKernel module

I always do what you wrote, but it doesn’t update kernel.json. After click “Install Slicer kernel in Jupyter” it fills the template with paths to SuperBuild/Slicer-build not to for example Slicer-2018.08.20-amd64/. Tested few times. I give a try for `slicer.app.extensionsManagerModel().installExtension()`, because can’t install builded and packed SlicerJupyter through GUI extension manager.

Maybe I will find some time in a break from my doctorate.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [September 19, 2018, 7:48pm UTC](https://discourse.slicer.org/t/workflow-with-docker-and-slicer/4091/8 "2018-09-19T19:48:42Z")

</div>

> [@darekdev](#):
>
> it doesn’t update kernel.json. After click “Install Slicer kernel in Jupyter” it fills the template with paths to SuperBuild/Slicer-build not to for example Slicer-2018.08.20-amd64/

Could you start Slicer using Jupyter, enter these commands and let us know what you got as output?

```
print slicer.app.launcherExecutableFilePath
print slicer.app.applicationFilePath()

```

Is this an installed Slicer or a custom-built Slicer run from the build tree?  
Is this an SlicerJupyter package installed or a custom-built SlicerJupyter left in the build tree?

> [@darekdev](#):
>
> with this envoronment I dont know why Slicer (when I connect to SlicerJupyter) has 100% CPU usage

I’ve updated SlicerJupyter with an option to use a timer instead of watching socket changes. This option ([JUPYTER\_POLL\_USING\_TIMER](https://github.com/Slicer/SlicerJupyter/blob/5216ba31c2dea77357b9d3d4b74f4b815ccecb76/JupyterKernel/xSlicerServer.h#L21-L25)) is enabled on Windows by default. Could you check if you build SlicerJupyter with this option enabled then your 100% CPU usage problem is resolved?

---

<div class="post-metadata">

### Author: ![darekdev](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@darekdev](https://discourse.slicer.org/u/darekdev)
#### Post date: [September 20, 2018, 8:57am UTC](https://discourse.slicer.org/t/workflow-with-docker-and-slicer/4091/9 "2018-09-20T08:57:23Z")

</div>

Answering to kernel.json:

1. I did something wrong with **kernel-template.json** (doesn’t exists). Works now.

2. I have a custom-build Slicer with built in SlicerJupyter. I used this script: [DOC: Script to build qt5 image, bundling external modules. · Issue #8 · Slicer/SlicerBuildEnvironment · GitHub](https://github.com/Slicer/SlicerBuildEnvironment/issues/8), because I can’t built SlicerJupyter standalone what is write here [GitHub - Slicer/SlicerBuildEnvironment: A repository of scripts to set up a Slicer build environment.](https://github.com/Slicer/SlicerBuildEnvironment#configure-build-and-package-a-slicer-extension-for-linux). I have an error:

3. Yes, I’m tracking an extension on github and I’m going answer there.

---

<div class="post-metadata">

### Author: ![Saima](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@Saima](https://discourse.slicer.org/u/Saima)
#### Post date: [February 3, 2023, 5:32am UTC](https://discourse.slicer.org/t/workflow-with-docker-and-slicer/4091/10 "2023-02-03T05:32:36Z")

</div>

Hi andras,  
I ran external python script with anaconda env using check\_output through slicer scripted module. It was running fine last time but it is now not returning to slicer.

The external python script is running but at the end a pop up window with forcequit comes. slicer crash…

When I open slicer using terminal. The terminal window is showing

Error response from daemon: No such container: greedy\_elephant  
Error: No such container: greedy\_elephant  
Error response from daemon: No such container: greedy\_elephant  
Error response from daemon: removal of container greedy\_elephant is already in progress

Could you please help.

Regards,  
Saima
