Singularity: Difference between revisions

Added text for running Singularity interactively
m (use tt rather than pre for non-command text)
(Added text for running Singularity interactively)
Line 189: Line 189:
===Creating/Updating an Image Interactively and Manually===
===Creating/Updating an Image Interactively and Manually===


This section is incomplete and will be completed later.
TODO: This section is incomplete and will be completed later.


===Is sudo Needed or Not Needed?===
===Is sudo Needed or Not Needed?===
Line 228: Line 228:
===Running Commands Interactively===
===Running Commands Interactively===


This section is incomplete and will be completed later.
Singularity can be used interactively by using its shell command, e.g.,
 
<source lang="console">$ singularity shell --help</source>
 
will give help on shell command usage. The following:
 
<source lang="console">$ singularity shell -B /home -B /project -B /scratch -B /localscratch myimage.simg</source>
 
will do the following within the container image <code>myimage.simg</code>:
* bind mount <code>/home</code> so that all home directories can be accessed (subject to your account's permissions)
* bind mount <code>/project</code> so that project directories can be accessed (subject to your account's permissions)
* bind mount <code>/scratch</code> so that the scratch directory can be accessed (subject to your account's permissions)
* bind mount <code>/localscratch</code> so that the localscratch directory can be accessed (subject to your account's permissions)
* run a shell (e.g., <code>/bin/bash</code>)
 
If this command is successful, you can interactively run commands from within your container while still being able to access your files in home, project, scratch, and localscratch. :-)
* NOTE: When done, type "exit" to exit the shell.
 
In some cases, you will not want the pollution of shell environment variables from your Compute Canada shell. You can run a "clean environment" shell by adding a <code>-e</code> option, e.g.,
 
<source lang="console">$ singularity shell -e -B /home -B /project -B /scratch -B /localscratch myimage.simg</source>
 
but know you may need to define some shell environment variables such as <code>$USER</code>.
 
Finally, if you are using Singularity interactively on your own machine, in order for your changes to the image to be written to the disk, you must:
 
* be using a Singularity "sandbox" image (i.e., be using a directory not the read-only .simg file)
* be using the <code>-w</code> option, and,
* be using <code>sudo</code>
 
e.g., first create your sandbox image:
 
<source lang="console">$ sudo singularity build -s myimage-dir myimage.simg</source>
 
and then engage with Singularity interactively:
 
<source lang="console">$ sudo singularity shell -w myimage-dir</source>
 
When done, you can build a new/updated simg file, with the command:
 
<source lang="console">$ sudo singularity build myimage-new.simg myimage-dir/</source>
 
and upload myimage-new.simg to a cluster in order to use it.


===Running a Single Command===
===Running a Single Command===
cc_staff
156

edits