CINXE.COM

Docker

<!doctype html> <html> <head lang="en"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link rel="icon" type="image/x-icon" href="../images/logos/phenix_logo.gif"> <!-- bootstrap framework --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"/> <link rel="stylesheet" href="../css/custom.css" type="text/css" /> <link rel="stylesheet" href="../css/highlight.css" type="text/css" /> <style> .carousel-inner > .item > img, .carousel-inner > .item > a > img { width: 70%; margin: auto; } </style> <title>Docker</title> </head> <body> <nav class="navbar justify-content-center sticky-top navbar-expand-md"> <!-- style="width: 1200px;" --> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a class="navbar-nav mr-auto" href="../index.html" style="color: #fff;font-size: 16px;"><!-- was nav-brand--> <!-- img src="/web/images/logos/phenix_logo_centered.png" height="24" Home &nbsp;&nbsp; --> <img src="../images/icons/house-24.png" height="24" width="24"></a> &nbsp;&nbsp;&nbsp; <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav mr-auto"> <li class="nav-item dropdown px-4"> <a class="nav-link dropdown-toggle" href="docker.html#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="color: #fff;">Experiment&nbsp;&nbsp;<img src="../images/icons/atomic-24.png" height="16" width="16"></a> <div class="dropdown-menu" aria-labelledby="navbarDropdown"> <div class="dropdown-item" style="color: #fff; background-color: #0062cc;">Overview&nbsp;<img src="../images/icons/arrow-216-32.png" height="8" width="8"/></div> <a class="dropdown-item" href="../experiment/concept.html" >Concept and History</a> <a class="dropdown-item" href="../experiment/bup.html" >Plans and Proposals</a> <a class="dropdown-item" href="../experiment/links.html" >Web Resources</a> <div class="dropdown-item" style="color: #fff; background-color: #0062cc;">Collaboration&nbsp;<img src="../images/icons/arrow-216-32.png" height="8" width="8"/></div> <a class="dropdown-item" href="../experiment/contact.html" >Contact Info</a> <a class="dropdown-item" href="../experiment/join.html" >Join PHENIX</a> <a class="dropdown-item" href="../experiment/members.html" >Current Members</a> <a class="dropdown-item" href="https://doi.org/10.5281/zenodo.6565092" target="_blank">PHENIX Bylaws&nbsp;&nbsp;<img src="../images/icons/external-link-32.png" height="16" width="16"></a> <div class="dropdown-item" style="color: #fff; background-color: #0062cc;">PHENIX Run Info&nbsp;<img src="../images/icons/arrow-216-32.png" height="8" width="8"/></div> <a class="dropdown-item" href="../experiment/runs.html" >Run Summary Table</a> <a class="dropdown-item" href="../experiment/auxiliary.html" >Misc Run Info</a> <a class="dropdown-item" href="../experiment/trigger.html" >Trigger Information</a> </div> </li> <li class="nav-item dropdown px-4"> <a class="nav-link dropdown-toggle" href="docker.html#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="color: #fff;">Results&nbsp;&nbsp;<img src="../images/icons/checked-checkbox-32.png" height="16" width="16"></a> <div class="dropdown-menu" aria-labelledby="navbarDropdown"> <div class="dropdown-item" style="color: #fff; background-color: #0062cc;">Publications&nbsp;<img src="../images/icons/arrow-216-32.png" height="8" width="8"/></div> <a class="dropdown-item" href="../results/inspire.html" >PHENIX papers (Inspire HEP)</a> <a class="dropdown-item" href="../results/legacy.html" >Top Cited Publications and the Data Archive</a> <a class="dropdown-item" href="../results/conferences.html" >Conference Presentations by PHENIX Members</a> <a class="dropdown-item" href="https://zenodo.org/communities/phenixcollaboration/search?page=1&size=20&q=thesis&type=publication&sort=-publication_date&subtype=thesis" target="_blank">PhD theses&nbsp;&nbsp;<img src="../images/icons/external-link-32.png" height="16" width="16"></a> <div class="dropdown-item" style="color: #fff; background-color: #0062cc;">HEPData&nbsp;<img src="../images/icons/arrow-216-32.png" height="8" width="8"/></div> <a class="dropdown-item" href="../results/hepdata_policy.html" >Policy and Procedure</a> <a class="dropdown-item" href="../results/hepdata_instructions.html" >Instructions</a> <a class="dropdown-item" href="https://www.hepdata.net/search/?collaboration=PHENIX" target="_blank">PHENIX on HEPData&nbsp;&nbsp;<img src="../images/icons/external-link-32.png" height="16" width="16"></a> <div class="dropdown-item" style="color: #fff; background-color: #0062cc;">OpenData&nbsp;<img src="../images/icons/arrow-216-32.png" height="8" width="8"/></div> <a class="dropdown-item" href="https://opendata-qa.cern.ch/search?page=1&size=20&experiment=PHENIX" target="_blank">PHENIX on OpenData&nbsp;&nbsp;<img src="../images/icons/external-link-32.png" height="16" width="16"></a> <div class="dropdown-item" style="color: #fff; background-color: #0062cc;">Zenodo&nbsp;<img src="../images/icons/arrow-216-32.png" height="8" width="8"/></div> <a class="dropdown-item" href="../results/zenodo.html" >About Zenodo</a> <a class="dropdown-item" href="../results/keywords.html" >PHENIX Keywords</a> </div> </li> <li class="nav-item dropdown px-4"> <a class="nav-link dropdown-toggle" href="docker.html#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="color: #fff;">Detectors&nbsp;&nbsp;<img src="../images/icons/cog-24.png" height="16" width="16"></a> <div class="dropdown-menu" aria-labelledby="navbarDropdown"> <div class="dropdown-item" style="color: #fff; background-color: #0062cc;">Overview&nbsp;<img src="../images/icons/arrow-216-32.png" height="8" width="8"/></div> <a class="dropdown-item" href="../detectors/overview.html" >Detectors Overview</a> <a class="dropdown-item" href="../detectors/phenix_photo_gallery.html" >PHENIX Photo Gallery</a> <a class="dropdown-item" href="../detectors/run_configuration_gallery.html" >Run Configuration Gallery</a> <div class="dropdown-item" style="color: #fff; background-color: #0062cc;">Subsystems&nbsp;<img src="../images/icons/arrow-216-32.png" height="8" width="8"/></div> <a class="dropdown-item" href="../detectors/central_arm.html" >Central Arm Detectors</a> <a class="dropdown-item" href="../detectors/muon_arm.html" >Muon Arm Detectors</a> <a class="dropdown-item" href="../detectors/event_characterization.html" >Event Characterization Detectors</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="../detectors/magnet.html" >Magnet</a> </div> </li> <li class="nav-item dropdown px-4"> <a class="nav-link dropdown-toggle" href="docker.html#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="color: #fff;">Offline Software&nbsp;&nbsp;<img src="../images/icons/console-24.png" height="16" width="16"></a> <div class="dropdown-menu" aria-labelledby="navbarDropdown"> <div class="dropdown-item" style="color: #fff; background-color: #0062cc;">Simulations&nbsp;<img src="../images/icons/arrow-216-32.png" height="8" width="8"/></div> <a class="dropdown-item" href="pisa.html" >PISA</a> <div class="dropdown-item" style="color: #fff; background-color: #0062cc;">Docker and REANA&nbsp;<img src="../images/icons/arrow-216-32.png" height="8" width="8"/></div> <a class="dropdown-item" href="docker_root.html" >ROOT in Containers</a> <a class="dropdown-item" href="docker.html" >Using Docker</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="reana.html" >REANA</a> <a class="dropdown-item" href="cwl.html" >Common Workflow Language</a> <div class="dropdown-item" style="color: #fff; background-color: #0062cc;">Misc&nbsp;<img src="../images/icons/arrow-216-32.png" height="8" width="8"/></div> <a class="dropdown-item" href="overview.html" >Notes on PHENIX Software</a> <a class="dropdown-item" href="fun4all.html" >Fun4All</a> <a class="dropdown-item" href="custom.html" >Custom Components</a> </div> </li> <li class="nav-item dropdown px-4"> <a class="nav-link dropdown-toggle" href="docker.html#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="color: #fff;">Analysis&nbsp;&nbsp;<img src="../images/icons/research-32.png" height="16" width="16"></a> <div class="dropdown-menu" aria-labelledby="navbarDropdown"> <div class="dropdown-item" style="color: #fff; background-color: #0062cc;">Write-ups&nbsp;<img src="../images/icons/arrow-216-32.png" height="8" width="8"/></div> <a class="dropdown-item" href="https://zenodo.org/communities/phenixcollaboration/search?page=1&size=20&q=tutorial" target="_blank">Misc PHENIX Tutorials&nbsp;&nbsp;<img src="../images/icons/external-link-32.png" height="16" width="16"></a> <a class="dropdown-item" href="https://zenodo.org/communities/phenixcollaboration/search?page=1&size=20&q=school21" target="_blank">PHENIX School 2021&nbsp;&nbsp;<img src="../images/icons/external-link-32.png" height="16" width="16"></a> <a class="dropdown-item" href="https://zenodo.org/communities/phenixcollaboration/search?page=1&size=20&q=school22" target="_blank">PHENIX School 2022&nbsp;&nbsp;<img src="../images/icons/external-link-32.png" height="16" width="16"></a> <a class="dropdown-item" href="../analysis/embeddingVtx.html" >Embedding Example (VTX)</a> <a class="dropdown-item" href="../analysis/dAuPi0Photon.html" >Direct &#611; in d+Au collisions</a> <a class="dropdown-item" href="../analysis/dimuon.html" >J/ψ in small systems (dimuon analysis)</a> <div class="dropdown-item" style="color: #fff; background-color: #0062cc;">Misc&nbsp;<img src="../images/icons/arrow-216-32.png" height="8" width="8"/></div> <a class="dropdown-item" href="../analysis/rivet.html" >Rivet</a> <a class="dropdown-item" href="../analysis/ananotes.html" >Analysis Notes</a> </div> </li> </ul><ul class="navbar-nav text-right"> <li class="nav-item dropdown px-4"> <a class="nav-link dropdown-toggle" href="docker.html#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="color: #fff;">About&nbsp;&nbsp;<img src="../images/icons/info-2-32.png" height="16" width="16"></a> <div class="dropdown-menu" aria-labelledby="navbarDropdown"> <a class="dropdown-item" href="../about/dap.html" >DAP&nbsp;&nbsp;<img src="../images/icons/gift-2-32.png" height="16" width="16"></a> <a class="dropdown-item" href="../about/site.html" >Help Needed!&nbsp;&nbsp;<img src="../images/icons/lifebuoy-32.png" height="16" width="16"></a> <a class="dropdown-item" href="../about/howto.html" >How to Contribute&nbsp;&nbsp;<img src="../images/icons/test-tube-5-32.png" height="16" width="16"></a> <a class="dropdown-item" href="../about/devs.html" >Developer's notes&nbsp;&nbsp;<img src="../images/icons/wrench-32.png" height="16" width="16"></a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="../about/contact.html" >The Team&nbsp;&nbsp;<img src="../images/icons/group-32.png" height="16" width="16"></a> </div> </li> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </ul> </div> </nav> <p/> <p/> <div class="container-fluid" style="min-width:1000px;padding-right:300px;padding-left:300px;"> <h3>Docker</h3> <ul id="markdown-toc"> <li><a href="docker.html#about-this-page" id="markdown-toc-about-this-page">About this page</a></li> <li><a href="docker.html#what-is-docker" id="markdown-toc-what-is-docker">What is Docker?</a></li> <li><a href="docker.html#running-the-latest-version-of-root-is-a-one-liner" id="markdown-toc-running-the-latest-version-of-root-is-a-one-liner">Running the latest version of ROOT is a one-liner</a></li> <li><a href="docker.html#caveats" id="markdown-toc-caveats">Caveats</a></li> <li><a href="docker.html#x11" id="markdown-toc-x11">X11</a> <ul> <li><a href="docker.html#server-access" id="markdown-toc-server-access">Server access</a></li> <li><a href="docker.html#shared-memory-access" id="markdown-toc-shared-memory-access">Shared memory access</a></li> <li><a href="docker.html#microsoft-windows" id="markdown-toc-microsoft-windows">Microsoft Windows</a></li> </ul> </li> <li><a href="docker.html#volumes" id="markdown-toc-volumes">Volumes</a></li> <li><a href="docker.html#custom-folders-and-other-customization" id="markdown-toc-custom-folders-and-other-customization">Custom folders and other customization</a></li> <li><a href="docker.html#running-docker-images-with-singularity" id="markdown-toc-running-docker-images-with-singularity">Running Docker images with Singularity</a></li> </ul> <h5 id="about-this-page">About this page</h5> <p><strong>This page is not meant to serve as a Docker tutorial or a reference</strong>, in particular because of abundance of helpful documentation easily available on the Web. Presented here are select instructions and examples which will be hopefully helpful to beginners wishing to leverage the capabilities of Docker for practical applications in PHENIX and other experiments. It is recommended that new users consult the main <a href="https://docs.docker.com/" target="_blank">Docker documentation page</a> for orientation, introduction and general reference. Consider going through some of the <a href="https://www.docker.com/101-tutorial" target="_blank">Docker tutorials</a>.</p> <p>For quickstart instructions on how to take advantage of running different versiond of ROOT in Docker containers please see the <a href="docker.html">“Running ROOT in Containers”</a> page.</p> <h5 id="what-is-docker">What is Docker?</h5> <p>Docker is a OS-level virtualization platform which allows complete software packages to run in isolation while utilizing the same kernel as the host operating system. This is the key distinction between Docker and the Virtual Machine technology which involves an entire level of emulation run on top of the host OS. A running instance of software managed by Docker is called a <em>container</em>, while the read-only template used to instantiate it is termed an <em>image</em>. This technology makes it possible to capture the complete software environment including a specific flavor of Linux chosen by the developer, compiled user code and all the necessary libraries and dependencies in a self-contained, portable package which can be run on any machine where Docker is installed. One of the motivations to consider Docker is its central role in the framework for reproducible analysis - <a href="docker.html">REANA</a>.</p> <p><strong>Docker can be <a href="https://docs.docker.com/engine/install/" target="_blank"> easily installed </a> on any Linux machine</strong> (exact method will depend on the Linux distribution), and in addition to that there is a “<a href="https://www.docker.com/products/docker-desktop" target="_blank">desktop application</a>” available for Linux, Windows and MacOS. Examples and tutorials can even be <a href="https://www.docker.com/play-with-docker" target="_blank">run in the cloud</a> without the need to install any software on your machine. An important part of every Docker development and workflow is a <em>registry</em> which serves as a storage and catalog of Docker <em>images</em>. A registry can be hosted locally or exist as a cloud service. A prominent cloud platform serving that purpose is <a href="https://hub.docker.com/" target="_blank">Docker Hub</a>.</p> <p>The following examples assume that Docker has been installed on the system. The docker daemon runs as <em>root</em> so all docker commands will need to be run via <em>sudo</em>. However, this can be avoided by adding users to a special <em>docker</em> group according to the instructions found on the Docker <a href="https://docs.docker.com/engine/install/linux-postinstall/" target="_blank">“post installation steps”</a> page.</p> <p>It is also possible to run Docker images using the <a href="https://sylabs.io/docs/" target="_blank">Singularity</a> containerization framework. Please see relevant Singularity documentation pages for details. Brief notes on how to do this on the interactive <a href="https://www.sdcc.bnl.gov/" target="_blank">SDCC</a> nodes at BNL can be found on the <a href="docker.html">“Running ROOT in Containers”</a> page.</p> <hr style="height:1px;border-width:0;color:royalblue;background-color:royalblue" /> <h5 id="running-the-latest-version-of-root-is-a-one-liner">Running the latest version of ROOT is a one-liner</h5> <p><em>The most current version of ROOT</em> can be run on a Docker-equipped machine with one command – no additional installation(s) required. In this example, Docker will locate the required <em>ROOT image</em> in the registry (e.g. Docker Hub which is usually the default), download it automatically, add it to the local cache and then start a <em>container process</em>. That process then proceeds to invoke the “root” command as specified on the command line. In the following command, the <em>‘-it’</em> option instructs Docker to run an interactive shell connected to the container, and the <em>’–rm’</em> is a cleanup option for your Docker environment (it is not critical for operation of the container itself).</p> <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker run <span class="nt">-it</span> <span class="nt">--rm</span> rootproject/root root <span class="c"># The user is presented wtih the usual ROOT prompt.</span> </code></pre></div></div> <hr style="height:1px;border-width:0;color:royalblue;background-color:royalblue" /> <h5 id="caveats">Caveats</h5> <ol> <li>In the example above, ROOT will indeed run interactively – in the command line mode – but likely without graphics. If the graphics capability is needed additional settings are required as detailed in the <em>“X11”</em> section below.</li> <li>In most cases, to use ROOT meaningfully the operator typically needs to exchange files between the host (your machine) and the container process. This may include input and output data as well as ROOT macros. It doesn’t happen by default – since containers run in isolation – so sharing of folders (“volumes”) has to be set up explicitely&gt; Fortunately, this is straightforward and is explained in the <em>“Volumes”</em> section below.</li> <li>A large number of PHENIX analysis have been done with ROOT versions 5.*. For example, in early 2021 ROOT version 5.34.36 was in use on interactive nodes of BNL SDCC. Using a consistent version of ROOT may be important for reproducibility of analyses and other purposes e.g. to ensure software compatibility. Specific instructions for <strong>running ROOT5 using Docker</strong> are given on the <a href="docker.html">“Running ROOT in Containers”</a> page.</li> <li>Platorm dependency - this is not a large issue but certain host systems may require extra runtime settings, see the <em>Windows</em> section below for an example.</li> </ol> <hr style="height:1px;border-width:0;color:royalblue;background-color:royalblue" /> <h5 id="x11">X11</h5> <h6 id="server-access">Server access</h6> <p>To enable container access to the X11 server on your machine requisite permissions need to be set. The easiest (but not very secure) way of doing this is as follows:</p> <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>xhost + </code></pre></div></div> <h6 id="shared-memory-access">Shared memory access</h6> <p>Some versions of the X11 server software require shared memory access for optimal performance, which may get in the way of proper graphics functionality of containers. This can be addressed in two different ways:</p> <ol> <li>Using the “ipc” option at runtime to enable interprocess communication between the container and the X11 server – theoretically, this will result in better performance.</li> <li>Disabling the shared memory mode of operation.</li> </ol> <p>Which version is best will depend on the needs of the user so some testing is recommended. Shown below are examples illustrating both options – either one should provide full graphics capability e.g. the usual TBrowser, canvas and other graphics tools.</p> <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Note proper security settings in both example.</span> <span class="c"># Examples tested on Ubuntu 18.04</span> <span class="c">#</span> <span class="c"># 1. Interprocess communication enabled, shared memory mode implied.</span> <span class="c"># NB. with this option the usual ROOT splash screen at start-up won't be shown.</span> docker run <span class="nt">-it</span> <span class="nt">--ipc</span><span class="o">=</span>host <span class="nt">--rm</span> <span class="nt">-e</span> <span class="nv">DISPLAY</span><span class="o">=</span><span class="nv">$DISPLAY</span> <span class="nt">-v</span> /tmp/.X11-unix:/tmp/.X11-unix rootproject/root root <span class="c">#</span> <span class="c"># 2. Shared memory functionality is disabled.</span> <span class="c"># 3. NB. the "Xauthority" file</span> <span class="c">#</span> docker run <span class="nt">-it</span> <span class="nt">--rm</span> <span class="nt">-e</span> <span class="nv">DISPLAY</span><span class="o">=</span><span class="nv">$DISPLAY</span> <span class="nt">-e</span> <span class="nv">QT_X11_NO_MITSHM</span><span class="o">=</span>1 <span class="nt">-v</span> /tmp/.X11-unix:/tmp/.X11-unix <span class="nt">--volume</span><span class="o">=</span><span class="s2">"</span><span class="nv">$HOME</span><span class="s2">/.Xauthority:/root/.Xauthority:rw"</span> rootproject/root root </code></pre></div></div> <p>Binding the <code class="language-plaintext highlighter-rouge">.Xauthority</code> may be necessary in the following examples as well, depending on specific configurtion of the system.</p> <h6 id="microsoft-windows">Microsoft Windows</h6> <p>There is an option <em>--security-opt</em> which is currently meaningful in the Windows environment only and may be needed for proper operation.</p> <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Please refer to Docker documentation for other details of the Windows environment.</span> <span class="c"># This command corresponds to the example above which disables the X11 memory sharing.</span> docker run <span class="nt">-it</span> <span class="nt">--rm</span> <span class="nt">-e</span> <span class="nv">DISPLAY</span><span class="o">=</span><span class="nv">$DISPLAY</span> <span class="nt">-e</span> <span class="nv">QT_X11_NO_MITSHM</span><span class="o">=</span>1 <span class="nt">--security-opt</span><span class="o">=</span><span class="s2">"label:disable"</span> <span class="nt">-v</span> /tmp/.X11-unix:/tmp/.X11-unix rootproject/root root </code></pre></div></div> <hr style="height:1px;border-width:0;color:royalblue;background-color:royalblue" /> <h5 id="volumes">Volumes</h5> <p>There are several ways to achieve sharing of volumes i.e. establishing storage area accessible from both the host and the container(s) running on the host. For detailed information, please see <a href="https://docs.docker.com/storage/volumes/" target="_blank">Docker documentation on volumes</a>. In the following, a basic example of utilizing volumes is presented, using just one method of several available. Let us assume that the image used to instantiate a container was created with a Dockerfile containing a directive similar to the following:</p> <div class="language-dockerfile highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">WORKDIR</span><span class="s"> /user</span> </code></pre></div></div> <p>A container (i.e. a running process) instantiated from this image will then have a directory named “/user” which is entirely internal to that container i.e. inaccessible from the host system. Now, let us assume that the operator issues the following command:</p> <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker volume create myvolume </code></pre></div></div> <p>This results in the creation of a <em>Docker volume</em> which is mapped to a specific location in the filesystem of the host machine. The exact name chosen for the volume is immaterial. To determine the location to which the volume is napped the following command can be used:</p> <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker volume inspect myvolume </code></pre></div></div> <p>…which will result in an output similar to:</p> <div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">[</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nl">"CreatedAt"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2021-02-06T20:10:06-05:00"</span><span class="p">,</span><span class="w"> </span><span class="nl">"Driver"</span><span class="p">:</span><span class="w"> </span><span class="s2">"local"</span><span class="p">,</span><span class="w"> </span><span class="nl">"Labels"</span><span class="p">:</span><span class="w"> </span><span class="p">{},</span><span class="w"> </span><span class="nl">"Mountpoint"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/var/lib/docker/volumes/myvolume/_data"</span><span class="p">,</span><span class="w"> </span><span class="nl">"Name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"user"</span><span class="p">,</span><span class="w"> </span><span class="nl">"Options"</span><span class="p">:</span><span class="w"> </span><span class="p">{},</span><span class="w"> </span><span class="nl">"Scope"</span><span class="p">:</span><span class="w"> </span><span class="s2">"local"</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">]</span><span class="w"> </span></code></pre></div></div> <p>The content of the volume will be kept in the directory pointed to by the “Mountpoint” attribute in the JSON output above. This directory is owned by <em>root</em> so access (including operations like “ls”) will only be possible using the root account or via sudo. Since the volume was just created it won’t have any content yet:</p> <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span><span class="nb">sudo ls</span> <span class="nt">-l</span> /var/lib/docker/volumes/myvolume/_data total 0 </code></pre></div></div> <p>Note that at this point the volume is unrelated to any specific Docker image and/or container. To establish binding of the volume to the container filesystem an option should be added to the “docker run command”, as in the following command line:</p> <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Running a ROOT5 image parepared by the PHENIX Collaboration</span> docker run <span class="nt">-it</span> <span class="nt">--ipc</span><span class="o">=</span>host <span class="nt">--rm</span> <span class="nt">-v</span> /tmp/.X11-unix:/tmp/.X11-unix <span class="nt">-v</span> myvolume:/user phenixcollaboration/tools:sl7_root5 </code></pre></div></div> <h5 id="custom-folders-and-other-customization">Custom folders and other customization</h5> <p>In the example above, the image used to instantiate the ROOT5 container has an internal folder “/user” defined. This is because the <a href="https://github.com/PhenixCollaboration/containers/blob/main/docker/sl7/Dockerfile.sl7_root5" target="_blank"><strong>Dockerfile</strong></a> used to create this image contained the requisite instruction</p> <div class="language-dockerfile highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">WORKDIR</span><span class="s"> /user</span> </code></pre></div></div> <p>There is nothing special about the “/user” name for this folder. Any names can be used and any folder hierarchy can be created to better suit the needs of the user’s work. It is not difficult to build customized images based on examples contained in the respective <a href="https://github.com/PhenixCollaboration/containers/tree/main/docker/sl7" target="_blank">PHENIX GitHub repository</a>. One can modify the Dockerfile and run the build locally, however be aware that a complete Docker build of ROOT will take a while. Alternatively, as a faster alternative, one can create a <em>customization layer</em> on top of an image already pushed to <a href="https://hub.docker.com/" target="_blank">Docker Hub</a>. The “base” ROOT5 image can be obtained and committed to local storage on the user’s machine by ising the command</p> <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker pull phenixcollaboration/tools:sl7_root5 </code></pre></div></div> <h5 id="running-docker-images-with-singularity">Running Docker images with Singularity</h5> <p>Docker images can also be used within the <a href="https://sylabs.io/docs/" target="_blank">Singularity</a> containerization framework. It has been deployed on SDCC nodes at BNL and is available by any user. For example, to start the SL7/ROOT5 image created by the PHENIX Collaboration and get to the <em>bash</em> prompt the following command can be used:</p> <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>singularity <span class="nb">exec</span> <span class="nt">--bind</span> /phenix/u/phnxuser:/user docker://phenixcollaboration/tools:sl7_root5 bash </code></pre></div></div> <p>In this example, the home directory of the user “phnxuser” will be mapped to the folder ‘/user’ which was defined in the image <em>sl7_root5</em>. For more detail please see information on folders presented above.</p> <p>The option <code class="language-plaintext highlighter-rouge">-B</code> allows the user to conveniently mout entrire directory trees.</p> <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>singularity <span class="nb">exec</span> <span class="nt">-B</span> /afs ... </code></pre></div></div> <p>Although ROOT can be started without invoking the shell first as it is the default command in the image, in this case this will be necessary to explicitly set the <em>DISPLAY</em> variable so that X11 tunneling properly works and X11 functionality is available. First, one determines the setting on the interactive node in use, which may look like</p> <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span><span class="nb">echo</span> <span class="nv">$DISPLAY</span> localhost:15.0 <span class="c"># actual value will vary</span> </code></pre></div></div> <p>Then, after invoking the “singularity exec” command as presented above, the user needs to set the environment variable accordingly by using the shell within the container:</p> <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span><span class="nb">export </span><span class="nv">DISPLAY</span><span class="o">=</span>localhost:15.0 </code></pre></div></div> <p>At that point, applications like xterm, emacs etc will properly function via X11. And, since this image also contains ROOT5, it can be invoked by typing “root” and will have the graphics capability.</p> <hr style="height:1px;border-width:0;color:royalblue;background-color:royalblue"/> <div class="page-footer text-center"> <a href="https://www.bnl.gov"> <img src="../images/logos/BNL_Logo_Horizontal_RGB_new_small.png" height=40 style="display:block; float:left"> </a> <img src="../images/logos/phenix_logo.gif" alt="PHENIX logo" height="60"> <a href="https://www.energy.gov/science/hep/high-energy-physics"> <img src="../images/logos/doe-logo-1024x257.png" height=30 style="display:block; float:right"> </a> </div> </div> <!-- container --> <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> <script> $(document).ready(function(){ // Activate Carousel $("#myCarousel").carousel({interval: 3000}); // Enable Carousel Indicators $(".item1").click(function(){ $("#myCarousel").carousel(0); }); $(".item2").click(function(){ $("#myCarousel").carousel(1); }); }); </script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10