Apptainer: Difference between revisions

Jump to navigation Jump to search
Line 118: Line 118:
===Running Software (Preferred): <code>apptainer run</code>===
===Running Software (Preferred): <code>apptainer run</code>===


The <code>apptainer run</code> command will launch an Apptainer container, run the <code>%runscript</code> defined for that container (if one is defined), and then run the specific command (subject to the code in the <code>%runscript</code> script). Using this command is preferred over using the <code>apptainer exec</code> command which directly runs a command within the specified container.
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). Using this command is preferred over using the <code>apptainer exec</code> command (which directly runs a command within the specified container).


For example, suppose you wanted to run the <code>g++</code> compiler inside your container to compile a C++ program called <code>myprog.cpp</code>. To this this you might run this:
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>. To this this you might use this command:


  apptainer run your-container-name.sif g++ -O2 -march=broadwell ./myprog.cpp
  apptainer run your-container-name.sif g++ -O2 -march=broadwell ./myprog.cpp
cc_staff
156

edits

Navigation menu