cc_staff
156
edits
Line 302: | Line 302: | ||
===Running Container Instances=== | ===Running Container Instances=== | ||
Should you need to run daemons and backgrounded processes within your container, then do '''not''' use the Singularity <code>exec</code> command! | |||
Instead you want to use Singularity's '''instance.start''' and '''instance.stop''' commands to create and destroy sessions (i.e., container instances). | |||
By using sessions, Singularity will ensure that your programs are terminated when your job ends, unexpectedly dies, is killed, etc. | |||
To start a Singularity session instance, decide on a name for this session, e.g., <code>quadrat5run</code>, and run the '''instance.start''' command | |||
specifying the image name, e.g., <code>myimage.simg</code>, and your session name: | |||
<source lang="console">$ singularity instance.start myimage.simg quadrat5run</source> | |||
A session (and all associated programs that are running) can be stopped (i.e., destroyed/killed) by running the '''instance.stop''' command, e.g., | |||
<source lang="console">$ singularity instance.stop myimage.simg quadrat5run</source> | |||
At any time you can obtain a list of all sessions you currently have running by running: | |||
<source lang="console">$ singularity instance.list</source> | |||
which will list the daemon name, its PID, and the path to the container's image. | |||
With a session started, programs can be run using Singularity's <code>shell</code>, <code>exec</code>, or <code>run</code> commands by specifying | |||
the name of the session immediately after the image name prefixed with '''instance://''', e.g., | |||
<source lang="console">$ singularity instance.start mysessionname | |||
$ singularity exec myimage.simg instance://mysessionname ps -eaf | |||
$ singularity shell myimage.simg instance://mysessionname | |||
nohup find / -type d >dump.txt | |||
exit | |||
$ singularity exec myimage.simg instance://mysessionname ps -eaf | |||
$ singularity instance.stop mysessionname | |||
</source> | |||
===Bind Mounts=== | ===Bind Mounts=== |