Warning, /EICrecon/docs/howto/use_docker.md is written in an unsupported language. File is not indexed.
0001 # Containers
0002
0003 ## Overview
0004
0005 The containers are released both for docker and singularity. Singularity images are automatically propagated to CVMFS:
0006
0007 - [Containers repository](https://eicweb.phy.anl.gov/containers)
0008 - [Docker Hub](https://hub.docker.com/u/eicweb)
0009 - CVMFS path (available at BNL and JLab):
0010 ```
0011 singularity run /cvmfs/singularity.opensciencegrid.org/eicweb/eic_xl:nightly
0012 ```
0013
0014 ### Images structure:
0015
0016 ![hierarchy](image-hierarhy.svg)
0017
0018
0019
0020 - **debian_base** - is a container generic base container based on amd64/debian:testing
0021 - **jug_dev** - have all major HENP packages such as ROOT, Geant4 and DD4HEP but without detector and reconstruction. The image is used for testing purposes and automation.
0022 - **eic_xl** - intended to be used to run simulation and work on detectors for users. jug_dev + full simulation packages
0023
0024
0025
0026 ### Versioning:
0027
0028
0029 - **nightly** - recreated every night, using master branches
0030 - **testing** - recreated every night, using fixed versions
0031 - **4.0-stable** - the latest stable version from 4.0 branch
0032 - **4.0.0** - exact tagged version
0033
0034
0035 Nightly and testing are different in that nightly uses the master branch of the software, while testing uses
0036 whatever version is given at the top of the [gitlab-ci.yml](https://eicweb.phy.anl.gov/containers/eic_container/-/blob/master/.gitlab-ci.yml#L68).
0037 So testing is the precursor to the next release version.
0038
0039
0040 **TL;DR;**
0041
0042 Now it is recommended to use: ```eicweb/eic_xl:nightly```
0043
0044
0045 ## Run in docker
0046
0047 Containers are available at eicweb namespace at
0048 [the dockerhub](https://hub.docker.com/u/eicweb)
0049
0050 To download or update the container:
0051
0052 ```bash
0053 docker pull eicweb/eic_xl:nightly
0054 ```
0055
0056 Running docker (minimal and probably useless):
0057
0058 ```bash
0059 docker run -it --rm eicweb/eic_xl:nightly
0060 ```
0061
0062
0063 ```--rm``` flag Docker **automatically cleans up the container** and remove the file system
0064 **when the container exits**. We use --rm flag for the sake of the tutorial repeatability. **If you work with the container,
0065 might be, you don't need it** (read more below).
0066
0067 ```-it``` flag enables interactive session. Without this flag ctrl+c will not work on Mac
0068 machines. In general `-it` is used to run e.g. bash session (see below)
0069
0070
0071 Each time `docker run` command is called, it spawns a new container.
0072 In particular, it first creates a writeable container layer over the
0073 specified image, and then starts it using the specified command. If `--rm` flag is not used,
0074 a stopped container can be restarted with all its previous changes intact using `docker start` command.
0075 Docker works somehow like tmux or screen - you can reconnect to the running image,
0076 attach many bash shells and even if container is stopped you can start it again and reconnect.
0077 This makes debugging easier, and you retain all your data. But `--rm` flag good for repeatability.
0078
0079 **Related docker documentation:**
0080
0081
0082 - [Docker run](https://docs.docker.com/engine/reference/commandline/run/)
0083 - [Docker start](https://docs.docker.com/engine/reference/commandline/start/)
0084 - [--rm flag](https://docs.docker.com/engine/reference/run/#clean-up---rm)
0085
0086
0087
0088 ## Select detector
0089
0090 The environment is set up with defaults, so you can use all the programs
0091 in the container as usual and assume everything needed to run the included software
0092 is already setup. But the detector needs to be selected for use with
0093 simulation or reconstruction:
0094
0095 ```bash
0096 # Detectors live in /opt/detector
0097 # One can select particular configuration as
0098 # source /opt/detector/epic-main/bin/thisepic.sh
0099 #
0100 source /opt/detector/epic-main/bin/thisepic.sh
0101 ```
0102
0103
0104
0105 ## Bind directories
0106
0107 You can bind any directory on your system to docker image by using **-v** flag:
0108
0109 ```
0110 -v <your/directory>:<docker/directory>
0111 ```
0112
0113 Convenient place inside docker image is `/mnt/` directory. Full example:
0114
0115 ```bash
0116 docker run -it -v /home/user/eic/data:/mnt/data --rm eicweb/eic_xl:nightly
0117 ls /mnt/data
0118 ```
0119
0120 **Related docker documentation:**
0121
0122 - [Docker bind](https://docs.docker.com/storage/bind-mounts/)
0123 - [Storage](https://docs.docker.com/storage/) (other mechanisms of how to manage data in docker)
0124
0125
0126 ## Code debugging
0127
0128 **Debugging** : To do C++ debugging (run GDB or so) one has to specify additional flags
0129 (the debugging is switched off by docker by default for security reasons):
0130
0131 ```--cap-add=SYS_PTRACE --security-opt seccomp=unconfined```
0132
0133 With debugging enabled and all ports open:
0134
0135 ```
0136 docker run -it --rm --cap-add=SYS_PTRACE --security-opt seccomp=unconfined eicweb/eic_xl:nightly
0137 ```
0138
0139
0140 ## Docker in IDEs
0141
0142 It might be a very convenient to use development tools (IDE's, debuggers, etc.)
0143 installed on your system, while using the docker to build, run and debug the code.
0144 The setup depends on particular tool:
0145
0146 - [Visual Studio Code docker remote debugging](https://code.visualstudio.com/docs/remote/remote-overview)
0147 - [CLion docker toolchain](https://www.jetbrains.com/help/clion/clion-toolchains-in-docker.html)
0148
0149 > Use `\usr\local\bin\cmake` as cmake path, when configuring IDEs with eic_xl image
0150
0151 ![vscode-docker](vscode_docker.png ':size=800')
0152
0153 ## X11 - Working with GUI
0154
0155 To use X11 directly require x11 client apps on Macs and Windows
0156 and may have some issues with user id's and permissions on Posix (max & linux).
0157 It might look complex, but actually it is not that bad and works most of the time.
0158
0159
0160 **Requirements**: X11 clients (windows and mac), additional docker flags (see of each OS)
0161
0162 You can use X11 natively (as natively as possible) with this docker image in your system:
0163
0164 ### Linux
0165
0166 To use graphics, make sure you are in an X11 session and run the following command:
0167
0168 ```bash
0169 docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --rm -it --user $(id -u) eicweb/eic_xl:nightly
0170 ```
0171
0172 There might be issues with user id on systems like JLab farms.
0173
0174 ### Windows
0175
0176 To enable graphics, you must have [VcXsrv](https://sourceforge.net/projects/vcxsrv/files/latest/download) installed.
0177 Make sure VcXsrv is whitelisted in the Windows firewall when prompted.
0178
0179 Start VcXsrv with 'allow from any origin' flag
0180
0181 ```bash
0182 docker run --rm -it -e LIBGL_ALWAIS_INDIRECT=1 -e DISPLAY=10.0.75.1:0 eicweb/eic_xl:nightly
0183 ```
0184
0185 > 10.0.75.1 address corresponds to the network configuration in docker settings
0186
0187
0188 ### OSX
0189
0190 To use graphics on OSX, make sure XQuarz is installed.
0191 After installing, open XQuartz, and go to XQuartz, Preferences, select the Security tab, and tick the box
0192 "Allow connections from network clients". Then exit XQuarz.
0193
0194 Afterwards, open a terminal and run the following commands:
0195
0196 ```bash
0197 ip=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
0198
0199 echo $ip # To make sure it was successful
0200 # If nothing is displayed, replace en0 with en1 and so on
0201
0202 xhost + $ip # start XQuartz and whitelist your local IP address
0203
0204 ```
0205
0206 This will start XQuartz and whitelist your local IP address.
0207
0208 Finally, you can start up docker with the following command:
0209
0210 ```
0211 docker run --rm -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$ip:0 eicweb/eic_xl:nightly
0212 ```
0213
0214
0215 ## Inherit image
0216
0217 If using this container as a basis for a new container, you can direct access
0218 the full container environment from a docker ``RUN`` shell command with no further
0219 action needed. For the most optimal experience, you can install your software to
0220 ``/usr/local`` to fully integrate with the existing environment. (Note that, internally,
0221 ``/usr/local`` is a symlink to ``/opt/view``).
0222
0223 ```
0224 FROM eicweb/eic_xl:nightly
0225 RUN apt-get update \
0226 && export DEBIAN_FRONTEND=noninteractive \
0227 && apt-get -y install git gdb
0228 ```