Apptainer: Difference between revisions

Jump to navigation Jump to search
Line 144: Line 144:
===Interactively Running Software: <code>apptainer shell</code>===
===Interactively Running Software: <code>apptainer shell</code>===


Text to come.
The <code>apptainer run</code>, <code>apptainer exec</code>, and <code>apptainer instance</code> commands run the programs provided and return after execution which makes them excellent for such and for use in BASH scripts and SLURM job scripts. That said, there are times when one needs to interactively do work inside a container. To run commands interactively while remaining inside a container, one uses the <code>apptainer shell</code> command.
 
For example, to run commands interactively in a container one first invokes the <code>apptainer shell</code> command, e.g.,
 
apptainer shell your-container-name.sif
 
where:
* <code>your-container-name.sif</code> is the name of your SIF file
 
Once the container starts, you will see an <code>Apptainer&gt;</code> prompt (or <code>Singularity&gt;</code> prompt if using Singularity). At this prompt you can run desired shell commands in the container. When done, type <code>exit</code> and hit the Enter/Return key to exit the container.
 
On our clusters, you will likely need to use a number of additional options (that appear after <code>run</code> and before <code>your-container-name.sif</code>). These options will include <code>-C</code>, <code>-c</code>, <code>-e</code>, <code>-W</code> as well as various bind mount options to make your disk space available to the programs that run in your container. For example:
 
  apptainer shell -C -W $SLURM_TMPDIR -B /home -B /project -B /scratch your-container-name.sif
 
For more information on these options see the following sections on this page:
 
* [[#Important_Command_Line_Options|Important Command Line Options]]
* [[#Using_GPUs|Using GPUs]]
* [[#Bind_Mounts_and_Persistent_Overlays|Bind Mounts and Persistent Overlays]]
 
as well as the [http://apptainer.org/docs/user/main/index.html official Apptainer documentation].
 
'''Important:''' In addition to choose to use the above options, if you are making use of a persistent overlay image (as a separate file or contained within the SIF file) with your container and want changes to be written to that image, it is extremely important to pass the <code>-w</code> or <code>--writable</code> option to your container. If this option is not passed to it, any changes you make to the image in the <code>apptainer shell</code> session will not be saved.


===Running Software (Basic): <code>apptainer exec</code>===
===Running Software (Basic): <code>apptainer exec</code>===
cc_staff
156

edits

Navigation menu