Using with Docker, cannot locate

Hello, I have been using Allpix Squared using Docker to directly simulate and so I have not built libraries on my machine, however I do have the Allpix source and example files loaded. I would like to now display Monte Carlo Hits using the script, but it requires me to point to , which I do not have on my machine. Is there any way to access this library via Docker? I had a tremendous amount of trouble getting all dependencies to run properly, which is why I would prefer to continue using Docker.

Hi Nashad,

I fear there is no simple solution to this. The ROOTObjectWriter writes the actual C++ objects created during the simulation into a ROOT tree. This allows us to keep all information, including cross-relationships, but also means that you need the actual library to read and interpret the objects.

Either you will have to run this analysis step inside the Docker container, or you will need an installation of Allpix Squared on your host. If you chose the latter option, you can drop the Geant4 requirement - simply switch off the respective modules (DepositionGeant4, GeometryBuilderGeant4, VisualizationGeant4) and compile without it. ROOT6 will still be necessary though.


Hi Simon,

Thank you for your response! I am still new to Docker so I apologise for the basic questions.

I’d like to first try to do the analysis within the Docker container. How can specify the library within the Docker container? As well, if you have any suggestions for materials to read for Docker documentation that is more specific to this type of application.

Any help is appreciated,

Hi Nashad,

unfortunately my experience with Docker is also limited to basic usage.

The library you are looking for should be located in /opt/allpix-squared/lib/ within the Docker image.



Thanks for the help!

I tried using this command:

$ docker run --tty --rm --name=allpix-squared2 "python tools/root_analysis_macros/ -l /opt/allpix-squared/lib/ -f output/data.root"

but I can’t seem to figure out how to make one flag (-f) point to a file in my local directory and the other flag (-l) point to a file within the Docker image. Is this something you are able to help with?

I have also done

 docker run --interactive --tty \
--volume "$(pwd)":/data \
--name=allpix-squared \ \

and can access an interactive shell using

docker run --rm -it --entrypoint=/bin/bash

however with this I still run into the issue of pointing flags towards files on my machine.

Hi Nashad,

it should be possible by running the container interactively, meaning with the “bash” option.
When being in there, you have access to the analysis tools and data, but also onto the /opt/ directory of the container.

I did the following:

docker run --interactive --tty --volume "$(pwd)":/data --name=allpix-squared bash
allpix -c conf/someConfig.conf
python tools/root_analysis_macros/ -f output/someOutput.root -l /opt/allpix-squared/lib/ -d someDetector

With this, the library is found. What is not found, however, is then numpy, scipy, matplotlib, because they are not included in the docker image… They have to be included in the image then somehow, which is again beyond my docker knowledge.

Hi All, thanks so much for the help.

For reference and any future users experiencing similar issues, I was able to solve my problem using the following (Note this can be done only once the image has been created as per the AllPix Squared manual):

docker run -it --entrypoint=/bin/bash --volume “$(pwd)”:/data

I learned that the --volume option allows you to connect a directory from within the docker container to view a directory on your machine. Using --volume "$(pwd)":/data connects the present working directory to a folder called “data”. In my present working directory, I kept my file and I also had a python script to install pip found here and ran it from the interactive shell using


I then installed NumPy, and Matplotlib using:

python -m pip install numpy
python -m pip install matplotlib

After that the last package I needed to install was TKinter, which is available via yum:

yum install tkinter

Note: At this point it is a VERY good idea to save the docker image so you don’t have to repeat this. (brief instructions on how to do that at the end)

Now, I could run the Python script (using the third command given by pschultze) was able to run up until the point at which it had to actually display the plots. It threw an error here because Docker did not have any way to open up a new window. There are many threads about workarounds for this, but I was unsuccessful in getting them to work. Instead, I worked around this problem by simply saving the plots rather than displaying them directly. I did this by editting the to have


and .savefig(“data/savefilename”) function with every plt.figure object. This allowed me to directly save the files onto my computer I’ll link a copy of my script later.

To save the docker image so you do not have to repeat steps above, open a new terminal and show the active containers using:

docker ps

This will return something similar to the following:

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
46b41bb3acba        9b5485e341bb        "/bin/bash"         5 seconds ago       Up 3 seconds                            gifted_brahmagupta

then commit using the following (replacing 46b41bb3acba with whatever your container ID is from above)

docker commit 46b41bb3acba <somename>

Now that your image is saved, you can access your image next time you use docker with

docker image ls

Which will return something like

REPOSITORY                                              TAG                 IMAGE ID            CREATED             SIZE
<somename>                                              latest              b5124f386ac7        11 seconds ago      4.99GB

And you can run the image by using the following command (Same as the first one in this comment, but with the image ID instead of the URL. Be sure to replace with your own image ID)

> docker run -it --entrypoint=/bin/bash --volume "$(pwd)":/data b5124f386ac7

Cheers to everyone who has helped.

Hi Nashad,

good to hear that this could be solved. Thanks for this review and the details, this is indeed useful!


@nashad The latest Docker image now includes the requested python modules, plus a few more: numpy, matplotlib, pandas, scipy. I hope this simplifies things.

It would be great if you could update your notes accordingly (after testing it of course) and maybe provide a merge request to include them in the Manual?