Apptainer: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 121: Line 121:


<!--T:28-->
<!--T:28-->
If you need to run MPI programs inside a container there are things that need to be done in the host environment in order for such to work. Please see the [[#Running_MPI_Programs_Inside_an_Apptainer Container|Running MPI Programs section below]] for an example of how to run MPI programs inside a container. The [http://apptainer.org/docs/user/main/mpi.html official Apptainer documentation] has more information concerning how MPI programs can be run inside a container.
If you need to run MPI programs inside a container, there are things that need to be done in the host environment in order for such to work. Please see the [[#Running_MPI_Programs_Inside_an_Apptainer Container|Running MPI Programs section below]] for an example of how to run MPI programs inside a container. The [http://apptainer.org/docs/user/main/mpi.html official Apptainer documentation] has more information concerning how MPI programs can be run inside a container.


==Container-specific help: <code>apptainer run-help</code>== <!--T:29-->
==Container-specific help: <code>apptainer run-help</code>== <!--T:29-->
Line 165: Line 165:


<!--T:42-->
<!--T:42-->
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 do this, you might use this command:


  <!--T:43-->
  <!--T:43-->
Line 177: Line 177:


<!--T:45-->
<!--T:45-->
On our clusters, you will want to use a number of additional options (that appear after <code>run</code> but 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:
On our clusters, you will want to use a number of additional options (that appear after <code>run</code>, but 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:


   <!--T:46-->
   <!--T:46-->
Line 271: Line 271:


<!--T:75-->
<!--T:75-->
where <code>./my_data_file.txt</code> is is a file in the current directory on the host, i.e., the file is not stored in the container at all. Because of the <code>-C</code> option, this file will not be accessible to the <code>wc</code> program inside the container --and so an access error will result. The fix is to bind mount the current directory, e.g.,
where <code>./my_data_file.txt</code> is a file in the current directory on the host, i.e., the file is not stored in the container at all. Because of the <code>-C</code> option, this file will not be accessible to the <code>wc</code> program inside the container --and so an access error will result. The fix is to bind mount the current directory, e.g.,


  <!--T:76-->
  <!--T:76-->
Line 425: Line 425:


<!--T:122-->
<!--T:122-->
Unfortunately some instructions for packages only provide a <code>Dockerfile</code> without a container image. A <code>Dockerfile</code> contains the instructions necessary for the Docker software to build that container. Our clusters do not have the Docker software installed. That said, if you've access to a system with both Docker and Apptainer installed, and, sufficient access to Docker (e.g., <code>sudo</code> or root access, or, you are in that system's <code>docker</code> group) and if needed Apptainer (e.g., <code>sudo</code> or root access, or, you have <code>--fakeroot</code> access), then you can follow the instructions below to use Docker and then Apptainer to build an Apptainer image on that system.
Unfortunately, some instructions for packages only provide a <code>Dockerfile</code> without a container image. A <code>Dockerfile</code> contains the instructions necessary for the Docker software to build that container. Our clusters do not have the Docker software installed. That said, if you've access to a system with both Docker and Apptainer installed, and, sufficient access to Docker (e.g., <code>sudo</code> or root access, or, you are in that system's <code>docker</code> group) and if needed Apptainer (e.g., <code>sudo</code> or root access, or, you have <code>--fakeroot</code> access), then you can follow the instructions below to use Docker and then Apptainer to build an Apptainer image on that system.


<!--T:123-->
<!--T:123-->
Line 450: Line 450:


<!--T:128-->
<!--T:128-->
After this is done, the SIF file is an Apptainer container for the <code>Dockerfile</code>. Transfer the SIF to the approprate cluster(s) in order to use such.
After this is done, the SIF file is an Apptainer container for the <code>Dockerfile</code>. Transfer the SIF to the appropriate cluster(s) in order to use such.


<!--T:129-->
<!--T:129-->
Line 460: Line 460:
<translate>
<translate>
<!--T:130-->
<!--T:130-->
followed by runninng <code>docker image rm ID</code> (where ID is the image ID output from the <code>docker images</code> command) in order to free up the disk space associated with those other image layers on the system you are using.
followed by running <code>docker image rm ID</code> (where ID is the image ID output from the <code>docker images</code> command) in order to free up the disk space associated with those other image layers on the system you are using.


=Miscellaneous items= <!--T:131-->
=Miscellaneous items= <!--T:131-->
rsnt_translations
56,420

edits