cc_staff
156
edits
Line 121: | Line 121: | ||
* <code>your-container-name.sif</code> is the name of your container | * <code>your-container-name.sif</code> is the name of your container | ||
===Running Software | ===Running Software=== | ||
====<code>apptainer run</code> or <code>apptainer exec</code>==== | |||
The <code>apptainer run</code> command will launch an Apptainer container, runs the <code>%runscript</code> defined for that container (if one is defined), and then runs the specific command (subject to the code in the <code>%runscript</code> script). | The <code>apptainer run</code> command will launch an Apptainer container, runs the <code>%runscript</code> defined for that container (if one is defined), and then runs the specific command (subject to the code in the <code>%runscript</code> script). | ||
* '''NOTE:''' Using | * '''NOTE:''' Using <code>apptainer run</code> command is preferred over using the <code>apptainer exec</code> command (which directly runs a command within the specified container). | ||
For example, suppose you want to run the <code>g++</code> compiler inside your container to compile a C++ program called <code>myprog.cpp</code> and then run that program. To this this you might use this command: | For example, suppose you want to run the <code>g++</code> compiler inside your container to compile a C++ program called <code>myprog.cpp</code> and then run that program. To this this you might use this command: | ||
Line 149: | Line 150: | ||
as well as the [http://apptainer.org/docs/user/main/index.html official Apptainer documentation]. | as well as the [http://apptainer.org/docs/user/main/index.html official Apptainer documentation]. | ||
===Interactively Running Software: <code>apptainer shell</code>=== | ====Interactively Running Software: <code>apptainer shell</code>==== | ||
The <code>apptainer run</code>, <code>apptainer exec</code>, and <code>apptainer instance</code> commands run the programs provided | The <code>apptainer run</code>, <code>apptainer exec</code>, and <code>apptainer instance</code> commands run the programs provided immediately which makes them excellent for use in BASH and SLURM job scripts. There are times when one needs to interactively do work inside a container. To run commands interactively while remaining inside a container, use the <code>apptainer shell</code> command instead. | ||
For example, to run commands interactively in a container one first invokes the <code>apptainer shell</code> command, e.g., | For example, to run commands interactively in a container one first invokes the <code>apptainer shell</code> command, e.g., | ||
Line 176: | Line 177: | ||
'''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) 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! | '''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) 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 Daemons: <code>apptainer instance</code>==== | ||
===Running Daemons: <code>apptainer instance</code>=== | |||
Apptainer has been designed to be able to properly run daemons within compute jobs on clusters. Running daemons is achieved, in part, by using <code>apptainer instance</code>. See the [http://apptainer.org/docs/user/main/running_services.html official Apptainer documentation on Running Services] for the details. | Apptainer has been designed to be able to properly run daemons within compute jobs on clusters. Running daemons is achieved, in part, by using <code>apptainer instance</code>. See the [http://apptainer.org/docs/user/main/running_services.html official Apptainer documentation on Running Services] for the details. |