cc_staff
153
edits
(Add translation markers) |
(Marked this version for translation) |
||
Line 1: | Line 1: | ||
<languages /> | <languages /> | ||
<translate> | <translate> | ||
=Forewords= | =Forewords= <!--T:1--> | ||
==Official Apptainer documentation== | ==Official Apptainer documentation== <!--T:2--> | ||
<!--T:3--> | |||
This page does not describe all features of Apptainer and does not replace [http://apptainer.org/docs Apptainer's official documentation]. It summarizes basic use, documents some aspects of using Apptainer on Alliance systems, and provides some relevant examples. We recommend you read the official Apptainer documentation concerning the features of Apptainer you are using. | This page does not describe all features of Apptainer and does not replace [http://apptainer.org/docs Apptainer's official documentation]. It summarizes basic use, documents some aspects of using Apptainer on Alliance systems, and provides some relevant examples. We recommend you read the official Apptainer documentation concerning the features of Apptainer you are using. | ||
<!--T:4--> | |||
Should you wish to install Apptainer on your own system, [http://apptainer.org/docs/user/main/quick_start.html#quick-installation instructions appear here]. If you are using a recent Windows system, install [https://learn.microsoft.com/en-us/windows/wsl/install|Windows Subsystem for Linux] first, then within such install Apptainer. If you are using a Mac, install a Linux distribution in a virtual machine on your computer first, then install Apptainer within such. | Should you wish to install Apptainer on your own system, [http://apptainer.org/docs/user/main/quick_start.html#quick-installation instructions appear here]. If you are using a recent Windows system, install [https://learn.microsoft.com/en-us/windows/wsl/install|Windows Subsystem for Linux] first, then within such install Apptainer. If you are using a Mac, install a Linux distribution in a virtual machine on your computer first, then install Apptainer within such. | ||
==If you are currently using Singularity== | ==If you are currently using Singularity== <!--T:5--> | ||
<!--T:6--> | |||
We strongly recommend that you use Apptainer instead of Singularity. SingularityCE (up to v3.9.5) was adopted by The Linux Foundation and renamed to Apptainer with these changes: | We strongly recommend that you use Apptainer instead of Singularity. SingularityCE (up to v3.9.5) was adopted by The Linux Foundation and renamed to Apptainer with these changes: | ||
<!--T:7--> | |||
* Added support for [https://dmtcp.sourceforge.io/ DMTCP checkpointing]. | * Added support for [https://dmtcp.sourceforge.io/ DMTCP checkpointing]. | ||
* Removed support for the <code>--nvccli</code> command line option. | * Removed support for the <code>--nvccli</code> command line option. | ||
Line 23: | Line 27: | ||
* Renamed all environment variables having <code>SINGULARITY</code> in their names to have <code>APPTAINER</code> in them. | * Renamed all environment variables having <code>SINGULARITY</code> in their names to have <code>APPTAINER</code> in them. | ||
<!--T:8--> | |||
Should you need to port scripts, etc. to Apptainer, know Apptainer version 1 is backwards compatible with Singularity so switching to Apptainer can be done incrementally. | Should you need to port scripts, etc. to Apptainer, know Apptainer version 1 is backwards compatible with Singularity so switching to Apptainer can be done incrementally. | ||
==Other Linux container technologies== | ==Other Linux container technologies== <!--T:9--> | ||
<!--T:10--> | |||
HPC clusters typically use Apptainer. Many users ask about other Linux container technologies so here are some with some comments: | HPC clusters typically use Apptainer. Many users ask about other Linux container technologies so here are some with some comments: | ||
* [https://podman.io/ Podman] | * [https://podman.io/ Podman] | ||
Line 37: | Line 43: | ||
** You can install and use Docker on your own computer and use it to create an Apptainer image, which can then be uploaded to an HPC cluster as outlined in '''[[#Creating_an_Apptainer_Container_From_a_Dockerfile|this section]]''' later on this page. | ** You can install and use Docker on your own computer and use it to create an Apptainer image, which can then be uploaded to an HPC cluster as outlined in '''[[#Creating_an_Apptainer_Container_From_a_Dockerfile|this section]]''' later on this page. | ||
==Other items== | ==Other items== <!--T:11--> | ||
===General=== | ===General=== | ||
* In order to use Apptainer you must have a container '''image''', e.g., a <code>.sif</code> file or a "sandbox" directory created previously. If you don't already have an image or a sandbox, see the section on '''[[#Building_an_Apptainer_Container/Image|building an image]]''' below. | * In order to use Apptainer you must have a container '''image''', e.g., a <code>.sif</code> file or a "sandbox" directory created previously. If you don't already have an image or a sandbox, see the section on '''[[#Building_an_Apptainer_Container/Image|building an image]]''' below. | ||
* While Apptainer is installed and available for use, using Apptainer will require you to install and/or build all software you will need to make use of in your container. In many instances, '''[[Available_software|we already have such software installed on our clusters]]''' so there is often no need to create a container with the same installed in it. | * While Apptainer is installed and available for use, using Apptainer will require you to install and/or build all software you will need to make use of in your container. In many instances, '''[[Available_software|we already have such software installed on our clusters]]''' so there is often no need to create a container with the same installed in it. | ||
===<code>sudo</code>=== | ===<code>sudo</code>=== <!--T:12--> | ||
Many users ask about <code>sudo</code> since documentation and web sites often discuss using <code>sudo</code>. Know the ability to use <code>sudo</code> to obtain superuser/root permissions is not available on our clusters. Should you require using <code>sudo</code>, consider the following options: | Many users ask about <code>sudo</code> since documentation and web sites often discuss using <code>sudo</code>. Know the ability to use <code>sudo</code> to obtain superuser/root permissions is not available on our clusters. Should you require using <code>sudo</code>, consider the following options: | ||
<!--T:13--> | |||
* Install Linux, Apptainer, and <code>sudo</code> in a virtual machine on a system you control so you will be able to have <code>sudo</code> access within such. Build your image(s) on that machine and upload them in order to use them on Alliance systems. | * Install Linux, Apptainer, and <code>sudo</code> in a virtual machine on a system you control so you will be able to have <code>sudo</code> access within such. Build your image(s) on that machine and upload them in order to use them on Alliance systems. | ||
* If appropriate, [[Technical Support|submit a ticket]] asking if Alliance staff would be able to help build the image(s), etc. required needing <code>sudo</code>. This may or may not be possible, but feel free to ask in a ticket if what you wish to achieve is beyond your means. Additionally, we may respond with other ways to achieve such which may or may not involve Apptainer. | * If appropriate, [[Technical Support|submit a ticket]] asking if Alliance staff would be able to help build the image(s), etc. required needing <code>sudo</code>. This may or may not be possible, but feel free to ask in a ticket if what you wish to achieve is beyond your means. Additionally, we may respond with other ways to achieve such which may or may not involve Apptainer. | ||
* Apptainer version 1.1.x and newer has improved support for users using <code>--fakeroot</code> implicitly and explicitly so some things may be possible that were not with Apptainer version 1.0 and Singularity. This includes being able to build some images from <code>.def</code> definition files and building some images without needing to use <code>sudo</code>. That said, not all images will be able to be built without needing to use <code>sudo</code> or superuser/root. | * Apptainer version 1.1.x and newer has improved support for users using <code>--fakeroot</code> implicitly and explicitly so some things may be possible that were not with Apptainer version 1.0 and Singularity. This includes being able to build some images from <code>.def</code> definition files and building some images without needing to use <code>sudo</code>. That said, not all images will be able to be built without needing to use <code>sudo</code> or superuser/root. | ||
===Building images or overlays=== | ===Building images or overlays=== <!--T:14--> | ||
Should you need to build your own container image(s) or overlay(s), be aware of the following: | Should you need to build your own container image(s) or overlay(s), be aware of the following: | ||
* Avoid building a sandbox image using <code>--fakeroot</code> on networked filesystem(s): [https://apptainer.org/docs/admin/main/installation.html#fakeroot-with-uid-gid-mapping-on-network-filesystems link to Apptainer documentation]. | * Avoid building a sandbox image using <code>--fakeroot</code> on networked filesystem(s): [https://apptainer.org/docs/admin/main/installation.html#fakeroot-with-uid-gid-mapping-on-network-filesystems link to Apptainer documentation]. | ||
Line 56: | Line 63: | ||
* Avoid using Lustre/GPFS filesystems as they don't have the feature set required to properly support building Apptainer containers (including <code>--fakeroot</code>): [https://apptainer.org/docs/admin/main/installation.html#lustre-gpfs link to Apptainer documentation]. | * Avoid using Lustre/GPFS filesystems as they don't have the feature set required to properly support building Apptainer containers (including <code>--fakeroot</code>): [https://apptainer.org/docs/admin/main/installation.html#lustre-gpfs link to Apptainer documentation]. | ||
=Loading an Apptainer module= | =Loading an Apptainer module= <!--T:15--> | ||
In order to use the default version of Apptainer available run: | In order to use the default version of Apptainer available run: | ||
<source lang="console">$ module load apptainer</source> | <source lang="console">$ module load apptainer</source> | ||
<!--T:16--> | |||
To see the available versions of Apptainer that can be loaded run: | To see the available versions of Apptainer that can be loaded run: | ||
<source lang="console">$ module spider apptainer</source> | <source lang="console">$ module spider apptainer</source> | ||
=Running programs within a container= | =Running programs within a container= <!--T:17--> | ||
==Important command line options== | ==Important command line options== <!--T:18--> | ||
<!--T:19--> | |||
Software that is run inside a container runs in a different environment using different libraries and tools than what is installed on the host system. It is, therefore, important to run programs within containers by '''not''' using any environment settings or software defined outside of the container. Unfortunately, by default, Apptainer will run adopting the shell environment of the host and this can result in issues when running programs. To avoid such issues, when using <code>apptainer run</code>, <code>apptainer shell</code>, <code>apptainer exec</code>, and/or </code>apptainer instance</code>, use one of these options (with more preference to those options listed earlier in the table below): | Software that is run inside a container runs in a different environment using different libraries and tools than what is installed on the host system. It is, therefore, important to run programs within containers by '''not''' using any environment settings or software defined outside of the container. Unfortunately, by default, Apptainer will run adopting the shell environment of the host and this can result in issues when running programs. To avoid such issues, when using <code>apptainer run</code>, <code>apptainer shell</code>, <code>apptainer exec</code>, and/or </code>apptainer instance</code>, use one of these options (with more preference to those options listed earlier in the table below): | ||
<!--T:20--> | |||
{| class="wikitable" | {| class="wikitable" | ||
|+Apptainer Environment Command Line Options | |+Apptainer Environment Command Line Options | ||
Line 81: | Line 91: | ||
|} | |} | ||
<!--T:21--> | |||
Another important option is the <code>-W</code> or <code>--workdir</code> option. On Alliance clusters and on most Linux systems, <code>/tmp</code> and similar filesystems use RAM, not disk space. Since jobs typically run on our clusters with limited RAM amounts, this can result in jobs getting killed because they consume too much RAM relative to what was requested for the job. A suitable work-around for this is to tell Apptainer to use a real disk location for its working directory ("workdir"). This is done by passing the <code>-W</code> option followed by a path to a disk location where Apptainer can read/write temporary files, etc. For example, suppose one wanted to run a command called <code>myprogram</code> in a using an Apptainer container image called <code>myimage.sif</code> with its "workdir" set to <code>/path/to/a/workdir</code> in the filesystem: | Another important option is the <code>-W</code> or <code>--workdir</code> option. On Alliance clusters and on most Linux systems, <code>/tmp</code> and similar filesystems use RAM, not disk space. Since jobs typically run on our clusters with limited RAM amounts, this can result in jobs getting killed because they consume too much RAM relative to what was requested for the job. A suitable work-around for this is to tell Apptainer to use a real disk location for its working directory ("workdir"). This is done by passing the <code>-W</code> option followed by a path to a disk location where Apptainer can read/write temporary files, etc. For example, suppose one wanted to run a command called <code>myprogram</code> in a using an Apptainer container image called <code>myimage.sif</code> with its "workdir" set to <code>/path/to/a/workdir</code> in the filesystem: | ||
<!--T:22--> | |||
<source lang="console">$ mkdir -p $HOME/aworkdir | <source lang="console">$ mkdir -p $HOME/aworkdir | ||
$ apptainer run -C -B /home -W /path/to/a/workdir myimage.sif myprogram</source> | $ apptainer run -C -B /home -W /path/to/a/workdir myimage.sif myprogram</source> | ||
<!--T:23--> | |||
where: | where: | ||
* The workdir can be removed if there are no live containers using it. | * The workdir can be removed if there are no live containers using it. | ||
Line 92: | Line 105: | ||
* When using bind mounts, see the [[#Bind_Mounts|section on bind mounts]] below since not all Alliance clusters are the same concerning the exact bind mounts needed to access <code>/home</code>, <code>/project</code>, and <code>/scratch</code>. | * When using bind mounts, see the [[#Bind_Mounts|section on bind mounts]] below since not all Alliance clusters are the same concerning the exact bind mounts needed to access <code>/home</code>, <code>/project</code>, and <code>/scratch</code>. | ||
==Using GPUs== | ==Using GPUs== <!--T:24--> | ||
<!--T:25--> | |||
When running software inside a container that requires the use of GPUs it is important to do the following: | When running software inside a container that requires the use of GPUs it is important to do the following: | ||
* Ensure that you pass the <code>--nv</code> (for NVIDIA hardware) and <code>--rocm</code> (for AMD hardware) to Apptainer commands. | * Ensure that you pass the <code>--nv</code> (for NVIDIA hardware) and <code>--rocm</code> (for AMD hardware) to Apptainer commands. | ||
Line 101: | Line 115: | ||
* When needing to use OpenCL inside the container, besides using the aforementioned options use the following bind mount: <code>-B /etc/OpenCL</code>. | * When needing to use OpenCL inside the container, besides using the aforementioned options use the following bind mount: <code>-B /etc/OpenCL</code>. | ||
<!--T:26--> | |||
An example of [[#Using_NVIDIA_GPUs_Within_an_Apptainer_Container|using NVIDIA GPUs within an apptainer container]] appears later on this page. | An example of [[#Using_NVIDIA_GPUs_Within_an_Apptainer_Container|using NVIDIA GPUs within an apptainer container]] appears later on this page. | ||
==Using MPI programs== | ==Using MPI programs== <!--T:27--> | ||
<!--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>== | ==Container-specific help: <code>apptainer run-help</code>== <!--T:29--> | ||
<!--T:30--> | |||
Apptainer containers built from [http://apptainer.org/docs/user/main/definition_files.html Definition files] often will have a <code>%help</code> section. To see this section run: | Apptainer containers built from [http://apptainer.org/docs/user/main/definition_files.html Definition files] often will have a <code>%help</code> section. To see this section run: | ||
apptainer run-help your-container-name.sif | <!--T:31--> | ||
apptainer run-help your-container-name.sif | |||
<!--T:32--> | |||
where: | where: | ||
* <code>your-container-name.sif</code> is the name of your container | * <code>your-container-name.sif</code> is the name of your container | ||
<!--T:33--> | |||
It is possible your container also has "apps" defined in it, you can get help for those apps by running: | It is possible your container also has "apps" defined in it, you can get help for those apps by running: | ||
apptainer run-help --app appname your-container-name.sif | <!--T:34--> | ||
apptainer run-help --app appname your-container-name.sif | |||
<!--T:35--> | |||
where: | where: | ||
* <code>appname</code> is the name of the app | * <code>appname</code> is the name of the app | ||
* <code>your-container-name.sif</code> is the name of your container | * <code>your-container-name.sif</code> is the name of your container | ||
<!--T:36--> | |||
To see a list of apps installed in your container (if there are any), run: | To see a list of apps installed in your container (if there are any), run: | ||
apptainer inspect --list-apps your-container-name.sif | <!--T:37--> | ||
apptainer inspect --list-apps your-container-name.sif | |||
<!--T:38--> | |||
where: | where: | ||
* <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: <code>apptainer run</code> or <code>apptainer exec</code>== | ==Running software: <code>apptainer run</code> or <code>apptainer exec</code>== <!--T:39--> | ||
<!--T:40--> | |||
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). | ||
<!--T:41--> | |||
* Using the <code>apptainer run</code> command is preferred over using the <code>apptainer exec</code> command (which directly runs a command within the specified container). | * Using the <code>apptainer run</code> command is preferred over using the <code>apptainer exec</code> command (which directly runs a command within the specified container). | ||
<!--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 this this you might use this command: | ||
apptainer run your-container-name.sif g++ -O2 -march=broadwell ./myprog.cpp | <!--T:43--> | ||
apptainer run your-container-name.sif g++ -O2 -march=broadwell ./myprog.cpp | |||
apptainer run your-container-name.sif ./a.out | apptainer run your-container-name.sif ./a.out | ||
<!--T:44--> | |||
where: | where: | ||
* <code>your-container-name.sif</code> is the name of your SIF file | * <code>your-container-name.sif</code> is the name of your SIF file | ||
* <code>g++ -O2 -march=broadwell ./myprog.cpp</code> is the command you want to run inside the container | * <code>g++ -O2 -march=broadwell ./myprog.cpp</code> is the command you want to run inside the container | ||
<!--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: | ||
apptainer run -C -W $SLURM_TMPDIR -B /home -B /project -B /scratch your-container-name.sif g++ -O2 -march=broadwell ./myprog.cpp | <!--T:46--> | ||
apptainer run -C -W $SLURM_TMPDIR -B /home -B /project -B /scratch your-container-name.sif g++ -O2 -march=broadwell ./myprog.cpp | |||
apptainer run -C -W $SLURM_TMPDIR -B /home -B /project -B /scratch ./a.out | apptainer run -C -W $SLURM_TMPDIR -B /home -B /project -B /scratch ./a.out | ||
<!--T:47--> | |||
For more information on these options see the following sections on this page: | For more information on these options see the following sections on this page: | ||
<!--T:48--> | |||
* [[#Important_Command_Line_Options|Important Command Line Options]] | * [[#Important_Command_Line_Options|Important Command Line Options]] | ||
* [[#Using_GPUs|Using GPUs]] | * [[#Using_GPUs|Using GPUs]] | ||
* [[#Bind_Mounts_and_Persistent_Overlays|Bind Mounts and Persistent Overlays]] | * [[#Bind_Mounts_and_Persistent_Overlays|Bind Mounts and Persistent Overlays]] | ||
<!--T:49--> | |||
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>== <!--T:50--> | ||
<!--T:51--> | |||
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. | 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. | ||
<!--T:52--> | |||
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., | ||
apptainer shell your-container-name.sif | <!--T:53--> | ||
apptainer shell your-container-name.sif | |||
<!--T:54--> | |||
where: | where: | ||
* <code>your-container-name.sif</code> is the name of your SIF file | * <code>your-container-name.sif</code> is the name of your SIF file | ||
<!--T:55--> | |||
Once the container starts, you will see an <code>Apptainer></code> prompt (or <code>Singularity></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. | Once the container starts, you will see an <code>Apptainer></code> prompt (or <code>Singularity></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. | ||
<!--T:56--> | |||
On our clusters, you will want 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: | On our clusters, you will want 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 | <!--T:57--> | ||
apptainer shell -C -W $SLURM_TMPDIR -B /home -B /project -B /scratch your-container-name.sif | |||
<!--T:58--> | |||
For more information on these options see the following sections on this page: | For more information on these options see the following sections on this page: | ||
<!--T:59--> | |||
* [[#Important_Command_Line_Options|Important Command Line Options]] | * [[#Important_Command_Line_Options|Important Command Line Options]] | ||
* [[#Using_GPUs|Using GPUs]] | * [[#Using_GPUs|Using GPUs]] | ||
* [[#Bind_Mounts_and_Persistent_Overlays|Bind Mounts and Persistent Overlays]] | * [[#Bind_Mounts_and_Persistent_Overlays|Bind Mounts and Persistent Overlays]] | ||
<!--T:60--> | |||
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]. | ||
<!--T:61--> | |||
'''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>== <!--T:62--> | ||
<!--T:63--> | |||
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. | ||
<!--T:64--> | |||
'''NOTE 1:''' Don't run daemons manually without using <code>apptainer instance</code> and related commands. Apptainer works properly with other tools such as the Slurm scheduler that run on our clusters. When a job is cancelled, killed, crashes, or is otherwise finished, daemons run using <code>apptainer instance</code> will not hang or result in defunct processes. Additionally by using the <code>apptainer instance</code> command you will be able to control the daemons and programs running in the same container. | '''NOTE 1:''' Don't run daemons manually without using <code>apptainer instance</code> and related commands. Apptainer works properly with other tools such as the Slurm scheduler that run on our clusters. When a job is cancelled, killed, crashes, or is otherwise finished, daemons run using <code>apptainer instance</code> will not hang or result in defunct processes. Additionally by using the <code>apptainer instance</code> command you will be able to control the daemons and programs running in the same container. | ||
<!--T:65--> | |||
'''NOTE 2:''' Running daemons in your job will only run those daemons while your job runs. The scheduler will kill all processes attached to a job when the granted job time expires. If you need to run daemons continuously for longer than a job, submit a ticket asking to discuss such with staff persons. Such may require creating a cloud virtual machine to achieve such. | '''NOTE 2:''' Running daemons in your job will only run those daemons while your job runs. The scheduler will kill all processes attached to a job when the granted job time expires. If you need to run daemons continuously for longer than a job, submit a ticket asking to discuss such with staff persons. Such may require creating a cloud virtual machine to achieve such. | ||
==Running MPI programs== | ==Running MPI programs== <!--T:66--> | ||
<!--T:67--> | |||
Running MPI programs within an Apptainer container across nodes likely will require special configuration. MPI exploits cluster interconnection hardware to communicate amongst nodes much more efficiently. Normally one does not need to worry about this since it is automatically done --except when running MPI programs across cluster nodes. | Running MPI programs within an Apptainer container across nodes likely will require special configuration. MPI exploits cluster interconnection hardware to communicate amongst nodes much more efficiently. Normally one does not need to worry about this since it is automatically done --except when running MPI programs across cluster nodes. | ||
<!--T:68--> | |||
'''NOTE:''' When all MPI processes are running on a single shared-memory node, there is no need to use interconnection hardware and there will be no issues running MPI programs within an Apptainer container when all MPI processes run on a single cluster node, e.g., when the slurm option <code>--nodes=1</code> is used with an <code>sbatch</code> script. Unless one '''explicitly''' sets the maximum number of cluster nodes used to <code>1</code>, the scheduler can choose to run an MPI program over multiple nodes. If such will run from within an Apptainer container and has not been set up to properly run, then it is possible it will fail to run. | '''NOTE:''' When all MPI processes are running on a single shared-memory node, there is no need to use interconnection hardware and there will be no issues running MPI programs within an Apptainer container when all MPI processes run on a single cluster node, e.g., when the slurm option <code>--nodes=1</code> is used with an <code>sbatch</code> script. Unless one '''explicitly''' sets the maximum number of cluster nodes used to <code>1</code>, the scheduler can choose to run an MPI program over multiple nodes. If such will run from within an Apptainer container and has not been set up to properly run, then it is possible it will fail to run. | ||
<!--T:69--> | |||
Text to come. | Text to come. | ||
=Bind mounts and persistent overlays= | =Bind mounts and persistent overlays= <!--T:70--> | ||
<!--T:71--> | |||
Often one will want to use either or both of these features in Apptainer: | Often one will want to use either or both of these features in Apptainer: | ||
* "bind mounts" are used to access disk space originating outside of the container, and, | * "bind mounts" are used to access disk space originating outside of the container, and, | ||
* "persistent overlays" are used to overlay a writable filesystem on an otherwise immutable (i.e., read-only) container image. | * "persistent overlays" are used to overlay a writable filesystem on an otherwise immutable (i.e., read-only) container image. | ||
==Bind mounts== | ==Bind mounts== <!--T:72--> | ||
<!--T:73--> | |||
When Apptainer is used with the <code>-C</code> or <code>-c</code> options, one will notice that they cannot access their disk space when inside the container. The remedy for this is to explicitly bind mount the disk space they wish to access. For example, suppose a user was using <code>-C</code> like this in an sbatch job to use apptainer: | When Apptainer is used with the <code>-C</code> or <code>-c</code> options, one will notice that they cannot access their disk space when inside the container. The remedy for this is to explicitly bind mount the disk space they wish to access. For example, suppose a user was using <code>-C</code> like this in an sbatch job to use apptainer: | ||
apptainer run -C -W $SLURM_TMPDIR a-container.sif wc -l ./my_data_file.txt | <!--T:74--> | ||
apptainer run -C -W $SLURM_TMPDIR a-container.sif wc -l ./my_data_file.txt | |||
<!--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 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., | ||
apptainer run -C -B . -W $SLURM_TMPDIR a-container.sif wc -l ./my_data_file.txt | <!--T:76--> | ||
apptainer run -C -B . -W $SLURM_TMPDIR a-container.sif wc -l ./my_data_file.txt | |||
<!--T:77--> | |||
where <code>-B .</code> will bind mount the current directory, <code>.</code>. | where <code>-B .</code> will bind mount the current directory, <code>.</code>. | ||
<!--T:78--> | |||
While one can have multiple bind mounts specified, often it is easier to specify the top directories of the filesystems one wishes to access. For example, on our clusters one might want to use: | While one can have multiple bind mounts specified, often it is easier to specify the top directories of the filesystems one wishes to access. For example, on our clusters one might want to use: | ||
apptainer run -C -B /home -B /project -B /scratch -W $SLURM_TMPDIR a-container.sif wc -l ./my_data_file.txt | <!--T:79--> | ||
apptainer run -C -B /home -B /project -B /scratch -W $SLURM_TMPDIR a-container.sif wc -l ./my_data_file.txt | |||
<!--T:80--> | |||
where: | where: | ||
* <code>-B /home</code> mounts the home filesystem | * <code>-B /home</code> mounts the home filesystem | ||
Line 230: | Line 291: | ||
* <code>-B /scratch</code> mounts the scratch filesystem | * <code>-B /scratch</code> mounts the scratch filesystem | ||
<!--T:81--> | |||
Doing this is especially useful when: | Doing this is especially useful when: | ||
* you need to access others' files on your research time in other locations, and/or, | * you need to access others' files on your research time in other locations, and/or, | ||
* you need to access files/directories some of which are symlinks to different locations that would/might otherwise be broken if you did not mount the entire filesystem. | * you need to access files/directories some of which are symlinks to different locations that would/might otherwise be broken if you did not mount the entire filesystem. | ||
<!--T:82--> | |||
If using these bind mounts do not work on the cluster you are using, then run this script to obtain the bind mount options you need to pass to Apptainer for /home, /project, and /scratch on that cluster: | If using these bind mounts do not work on the cluster you are using, then run this script to obtain the bind mount options you need to pass to Apptainer for /home, /project, and /scratch on that cluster: | ||
</translate> | </translate> | ||
Line 240: | Line 303: | ||
<translate> | <translate> | ||
<!--T:83--> | |||
It should be mentioned that a bind mount does not need to be in the same location inside the container: one can bind mount any file or directory to be at a different location, e.g., | It should be mentioned that a bind mount does not need to be in the same location inside the container: one can bind mount any file or directory to be at a different location, e.g., | ||
apptainer run -C -B ./my_data_file.txt:/special/input.dat -W $SLURM_TMPDIR a-container.sif wc -l /special/input.dat | <!--T:84--> | ||
apptainer run -C -B ./my_data_file.txt:/special/input.dat -W $SLURM_TMPDIR a-container.sif wc -l /special/input.dat | |||
<!--T:85--> | |||
i.e., <code>-B ./my_data_file.txt:/special/input.dat</code> bind mount maps the file <code>./my_data_file.txt</code> to be the file <code>/special/input.dat</code> inside the container and the <code>wc</code> command now processes that file. This feature can be useful when programs/scripts inside the container have hard-coded paths to files and directories that must be located in certain locations. | i.e., <code>-B ./my_data_file.txt:/special/input.dat</code> bind mount maps the file <code>./my_data_file.txt</code> to be the file <code>/special/input.dat</code> inside the container and the <code>wc</code> command now processes that file. This feature can be useful when programs/scripts inside the container have hard-coded paths to files and directories that must be located in certain locations. | ||
<!--T:86--> | |||
Finally, '''don't mount our CVMFS paths''' inside your containers as this is fraught with perils and defeats many reasons to use a container. The programs needed to be run inside a container need to be completely inside the container --don't introduce even more programs inside the container that don't need to be inside the container. | Finally, '''don't mount our CVMFS paths''' inside your containers as this is fraught with perils and defeats many reasons to use a container. The programs needed to be run inside a container need to be completely inside the container --don't introduce even more programs inside the container that don't need to be inside the container. | ||
==Persistent overlays== | ==Persistent overlays== <!--T:87--> | ||
<!--T:88--> | |||
Please refer to Apptainer documentation page about [https://apptainer.org/docs/user/main/persistent_overlays.html persistent overlays]. | Please refer to Apptainer documentation page about [https://apptainer.org/docs/user/main/persistent_overlays.html persistent overlays]. | ||
=Building an Apptainer image= | =Building an Apptainer image= <!--T:89--> | ||
==Overview== | ==Overview== | ||
<!--T:90--> | |||
'''NOTE:''' Please note and heed the advice concerning building images/overlays given '''[[#Building_Images.2FOverlays|earlier on this page]]'''. | '''NOTE:''' Please note and heed the advice concerning building images/overlays given '''[[#Building_Images.2FOverlays|earlier on this page]]'''. | ||
<!--T:91--> | |||
Apptainer "images" can be created in the following formats: | Apptainer "images" can be created in the following formats: | ||
<!--T:92--> | |||
* as an <code>SIF</code> file, or, | * as an <code>SIF</code> file, or, | ||
* as a "sandbox" directory. | * as a "sandbox" directory. | ||
<!--T:93--> | |||
<code>SIF</code> files internally can contain multiple parts where each part is typically a squashfs filesystem (which are read-only and compressed). It is possible for <code>SIF</code> files to contain read-write filesystems and overlay images as well --but such is beyond the scope of this page: see the official Apptainer documentation on how to do such. Unless more advanced methods of building an "image" were used, the Apptainer <code>build</code> command produces a <code>SIF</code> file with a read-only squashfs filesystem when building images. (This is the preferred option since the resulting image remains as-is since it is read-only, and, the image is much smaller since it is compressed. Know that disk reads from that image are done very quickly.) | <code>SIF</code> files internally can contain multiple parts where each part is typically a squashfs filesystem (which are read-only and compressed). It is possible for <code>SIF</code> files to contain read-write filesystems and overlay images as well --but such is beyond the scope of this page: see the official Apptainer documentation on how to do such. Unless more advanced methods of building an "image" were used, the Apptainer <code>build</code> command produces a <code>SIF</code> file with a read-only squashfs filesystem when building images. (This is the preferred option since the resulting image remains as-is since it is read-only, and, the image is much smaller since it is compressed. Know that disk reads from that image are done very quickly.) | ||
<!--T:94--> | |||
A "sandbox" directory is a normal directory in the filesystem that starts out as empty and as Apptainer builds the image it adds the files, etc. needed in the image to that directory. The contents of a "sandbox" directory should only be accessed, updated, etc. through the use of Apptainer. One might need to use a "sandbox" directory in situations where one needs to have read-write access to the image itself in order to be able to update the container image. That said, if updates are infrequent, it is typically easier and better to use an <code>SIF</code> and when updates need to be done, build a sandbox image from the <code>SIF</code> file, make the required changes, and then build a new <code>SIF</code> file, e.g., | A "sandbox" directory is a normal directory in the filesystem that starts out as empty and as Apptainer builds the image it adds the files, etc. needed in the image to that directory. The contents of a "sandbox" directory should only be accessed, updated, etc. through the use of Apptainer. One might need to use a "sandbox" directory in situations where one needs to have read-write access to the image itself in order to be able to update the container image. That said, if updates are infrequent, it is typically easier and better to use an <code>SIF</code> and when updates need to be done, build a sandbox image from the <code>SIF</code> file, make the required changes, and then build a new <code>SIF</code> file, e.g., | ||
<!--T:95--> | |||
<source lang="console">$ cd $HOME | <source lang="console">$ cd $HOME | ||
$ mkdir mynewimage.dir | $ mkdir mynewimage.dir | ||
Line 275: | Line 349: | ||
$ rm -rf mynewimage.dir</source> | $ rm -rf mynewimage.dir</source> | ||
<!--T:96--> | |||
Using an <code>SIF</code> image is recommended as disk performance (from the container image) will be faster than storing each file, etc. separately on Alliance cluster filesystems (which are set up to handle large files and parallel I/O). Using an <code>SIF</code> file instead of a sandbox image will also only use a quota file count amount of 1 instead of thousands (e.g., images will typically contain thousands of files and directories). | Using an <code>SIF</code> image is recommended as disk performance (from the container image) will be faster than storing each file, etc. separately on Alliance cluster filesystems (which are set up to handle large files and parallel I/O). Using an <code>SIF</code> file instead of a sandbox image will also only use a quota file count amount of 1 instead of thousands (e.g., images will typically contain thousands of files and directories). | ||
<!--T:97--> | |||
Many Linux distributions' package managers require root in order to use them. This implies that Apptainer version 1.0.x and the older Singularity cannot be used on compute clusters to build images as a normal user. Should such occur, submit a ticket asking for help to create that image or use a computer with Apptainer installed and you have root permissions. | Many Linux distributions' package managers require root in order to use them. This implies that Apptainer version 1.0.x and the older Singularity cannot be used on compute clusters to build images as a normal user. Should such occur, submit a ticket asking for help to create that image or use a computer with Apptainer installed and you have root permissions. | ||
<!--T:98--> | |||
Apptainer has a <code>--fakeroot</code> feature that can be used to build and manipulate images. Before Apptainer version 1.1, one wanting to use this feature on a cluster requires submitting a ticket requesting a system administrator to consider adding that person so Apptainer's <code>--fakeroot</code> for a specific cluster. (This may or may not be done --such will be responded to in that ticket.) With Apptainer version 1.1, <code>--fakeroot</code> can be used without being formally added. | Apptainer has a <code>--fakeroot</code> feature that can be used to build and manipulate images. Before Apptainer version 1.1, one wanting to use this feature on a cluster requires submitting a ticket requesting a system administrator to consider adding that person so Apptainer's <code>--fakeroot</code> for a specific cluster. (This may or may not be done --such will be responded to in that ticket.) With Apptainer version 1.1, <code>--fakeroot</code> can be used without being formally added. | ||
<!--T:99--> | |||
Know that some containers will not build successfully without using a <code>root</code> account to build them. These images cannot be built on our clusters. | Know that some containers will not build successfully without using a <code>root</code> account to build them. These images cannot be built on our clusters. | ||
<!--T:100--> | |||
If all you need is to use a Docker image as-is with Apptainer, often those images can be built and run without issues, e.g., without any need to have additional permissions or explicitly use <code>--fakeroot</code>. Should you need to modify the image after creating it, such may require elevated permissions to successfully do this, e.g., if the image's Linux distribution's package manager requires such and you need to install a package using it. For this reason, the examples shown below assume one only needs to use a Docker image as-is. | If all you need is to use a Docker image as-is with Apptainer, often those images can be built and run without issues, e.g., without any need to have additional permissions or explicitly use <code>--fakeroot</code>. Should you need to modify the image after creating it, such may require elevated permissions to successfully do this, e.g., if the image's Linux distribution's package manager requires such and you need to install a package using it. For this reason, the examples shown below assume one only needs to use a Docker image as-is. | ||
==Building a SIF image== | ==Building a SIF image== <!--T:101--> | ||
<!--T:102--> | |||
'''NOTE:''' Please note and heed the advice concerning building images/overlays given '''[[#Building_Images.2FOverlays|earlier on this page]]'''. | '''NOTE:''' Please note and heed the advice concerning building images/overlays given '''[[#Building_Images.2FOverlays|earlier on this page]]'''. | ||
<!--T:103--> | |||
To build an Apptainer SIF file image from Docker's latest available busybox image, use the <code>apptainer build</code> command: | To build an Apptainer SIF file image from Docker's latest available busybox image, use the <code>apptainer build</code> command: | ||
<source lang="console">$ apptainer build bb.sif docker://busybox</source> | <source lang="console">$ apptainer build bb.sif docker://busybox</source> | ||
<!--T:104--> | |||
See the [https://apptainer.org/docs Apptainer documentation] for more advanced aspects of building images. | See the [https://apptainer.org/docs Apptainer documentation] for more advanced aspects of building images. | ||
==Building a sandbox image== | ==Building a sandbox image== <!--T:105--> | ||
<!--T:106--> | |||
'''NOTE:''' Please note and heed the advice concerning building images/overlays given '''[[#Building_Images.2FOverlays|earlier on this page]]'''. | '''NOTE:''' Please note and heed the advice concerning building images/overlays given '''[[#Building_Images.2FOverlays|earlier on this page]]'''. | ||
<!--T:107--> | |||
In order to build a "sandbox" directory instead of an <code>SIF</code> file instead of providing an <code>SIF</code> file name, instead provide <code>--sandbox DIR_NAME</code> or <code>-s DIR_NAME</code> where <code>DIR_NAME</code> is the name of the to-be-created-directory where you want your "sandbox" image. For example, if the <code>apptainer build</code> command to create an <code>SIF</code> file was: | In order to build a "sandbox" directory instead of an <code>SIF</code> file instead of providing an <code>SIF</code> file name, instead provide <code>--sandbox DIR_NAME</code> or <code>-s DIR_NAME</code> where <code>DIR_NAME</code> is the name of the to-be-created-directory where you want your "sandbox" image. For example, if the <code>apptainer build</code> command to create an <code>SIF</code> file was: | ||
<source lang="console">$ apptainer build bb.sif docker://busybox</source> | <source lang="console">$ apptainer build bb.sif docker://busybox</source> | ||
Line 303: | Line 387: | ||
<source lang="console">$ apptainer build --sandbox bb.dir docker://busybox</source> | <source lang="console">$ apptainer build --sandbox bb.dir docker://busybox</source> | ||
<!--T:108--> | |||
Differences between building a "sandbox" image and a (normal) <code>SIF</code> file are: | Differences between building a "sandbox" image and a (normal) <code>SIF</code> file are: | ||
<!--T:109--> | |||
* the <code>SIF</code> file's image will be contained in a single file, compressed, and read-only, | * the <code>SIF</code> file's image will be contained in a single file, compressed, and read-only, | ||
* the "sandbox" image will be placed in a directory, uncompressed, may contain thousands of files (depending on what exactly is in the image), and will be able to be read-write. | * the "sandbox" image will be placed in a directory, uncompressed, may contain thousands of files (depending on what exactly is in the image), and will be able to be read-write. | ||
<!--T:110--> | |||
Within an account, using a "sandbox" directory will consume significant amounts of both disk space and file count quotas, thus, if read-write access to the underlying image is not normally required, you are advised to use an <code>SIF</code> instead. Additionally, using an <code>SIF</code> file will have higher disk access speeds to content contained within the <code>SIF</code> file. | Within an account, using a "sandbox" directory will consume significant amounts of both disk space and file count quotas, thus, if read-write access to the underlying image is not normally required, you are advised to use an <code>SIF</code> instead. Additionally, using an <code>SIF</code> file will have higher disk access speeds to content contained within the <code>SIF</code> file. | ||
=Example use cases= | =Example use cases= <!--T:111--> | ||
==Using Conda in Apptainer == | ==Using Conda in Apptainer == <!--T:112--> | ||
<!--T:113--> | |||
Text to come. | Text to come. | ||
==Using Spack in Apptainer == | ==Using Spack in Apptainer == <!--T:114--> | ||
<!--T:115--> | |||
Text to come. | Text to come. | ||
==Using NVIDIA GPUs in Apptainer == | ==Using NVIDIA GPUs in Apptainer == <!--T:116--> | ||
<!--T:117--> | |||
Text to come. | Text to come. | ||
==Running MPI programs in Apptainer == | ==Running MPI programs in Apptainer == <!--T:118--> | ||
<!--T:119--> | |||
Text to come. | Text to come. | ||
==Creating an Apptainer container from a Dockerfile== | ==Creating an Apptainer container from a Dockerfile== <!--T:120--> | ||
<!--T:121--> | |||
'''NOTE: This section requires you to install and use Docker and Apptainer on a system where you have appropriate privileges. These instructions will ''not'' work on our compute clusters.''' | '''NOTE: This section requires you to install and use Docker and Apptainer on a system where you have appropriate privileges. These instructions will ''not'' work on our compute clusters.''' | ||
<!--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--> | |||
'''NOTE:''' Using Docker may fail if you are not in the <code>docker</code> group. Similarly, building some containers may fail with Apptainer without appropriate <code>sudo</code>, root, or <code>--fakeroot</code> permissions. It is your responsibility to ensure you've such access on the system you are running the commands below. | '''NOTE:''' Using Docker may fail if you are not in the <code>docker</code> group. Similarly, building some containers may fail with Apptainer without appropriate <code>sudo</code>, root, or <code>--fakeroot</code> permissions. It is your responsibility to ensure you've such access on the system you are running the commands below. | ||
<!--T:124--> | |||
If one only has a Dockerfile and wishes to create an Apptainer image, run the following on a computer with Docker and Apptainer installed (where you've sufficient permissions, etc.): | If one only has a Dockerfile and wishes to create an Apptainer image, run the following on a computer with Docker and Apptainer installed (where you've sufficient permissions, etc.): | ||
docker build -f Dockerfile -t your-tag-name | <!--T:125--> | ||
docker build -f Dockerfile -t your-tag-name | |||
docker save your-tag-name -o your-tarball-name.tar | docker save your-tag-name -o your-tarball-name.tar | ||
docker image rm your-tag-name | docker image rm your-tag-name | ||
Line 344: | Line 440: | ||
rm your-tarball-name.tar | rm your-tarball-name.tar | ||
<!--T:126--> | |||
where: | where: | ||
<!--T:127--> | |||
* <code>your-tag-name</code> is a name you make up that will identify the container created in Docker | * <code>your-tag-name</code> is a name you make up that will identify the container created in Docker | ||
* <code>your-tarball-name.tar</code> is a filename you create that Docker will save the generated content of the container to | * <code>your-tarball-name.tar</code> is a filename you create that Docker will save the generated content of the container to | ||
Line 351: | Line 449: | ||
* <code>your-sif-name.sif</code> is the name of the Apptainer SIF file for the Apptainer container | * <code>your-sif-name.sif</code> is the name of the Apptainer SIF file for the Apptainer container | ||
<!--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 approprate cluster(s) in order to use such. | ||
<!--T:129--> | |||
'''NOTE:''' It is possible that the Dockerfile pulled in more layers which means you will have to manually delete those additional layers by running: | '''NOTE:''' It is possible that the Dockerfile pulled in more layers which means you will have to manually delete those additional layers by running: | ||
</translate> | </translate> | ||
Line 359: | Line 459: | ||
<translate> | <translate> | ||
<!--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 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. | ||
=Miscellaneous Items= | =Miscellaneous Items= <!--T:131--> | ||
==Cleaning Apptainer's cache directory== | ==Cleaning Apptainer's cache directory== <!--T:132--> | ||
<!--T:133--> | |||
Over time Apptainer's file cache will grow. To see where these files are run: | Over time Apptainer's file cache will grow. To see where these files are run: | ||
</translate> | </translate> | ||
Line 371: | Line 473: | ||
<translate> | <translate> | ||
<!--T:134--> | |||
and to remove those files, run: | and to remove those files, run: | ||
</translate> | </translate> | ||
Line 377: | Line 480: | ||
<translate> | <translate> | ||
==Changing Apptainer's default directories== | ==Changing Apptainer's default directories== <!--T:135--> | ||
<!--T:136--> | |||
You can override Apptainer's default temporary and cache directories by setting these environment variables before running <code>apptainer</code>: | You can override Apptainer's default temporary and cache directories by setting these environment variables before running <code>apptainer</code>: | ||
<!--T:137--> | |||
* <code>APPTAINER_CACHEDIR</code>: the directory where Apptainer will download and cache files | * <code>APPTAINER_CACHEDIR</code>: the directory where Apptainer will download and cache files | ||
* <code>APPTAINER_TMPDIR</code>: the directory where Apptainer will write temporary files including when building (squashfs) images | * <code>APPTAINER_TMPDIR</code>: the directory where Apptainer will write temporary files including when building (squashfs) images | ||
<!--T:138--> | |||
For example, to tell Apptainer to use your scratch space for its cache and temporary files (which is might be a better location), one might run: | For example, to tell Apptainer to use your scratch space for its cache and temporary files (which is might be a better location), one might run: | ||
</translate> | </translate> | ||
Line 392: | Line 498: | ||
<translate> | <translate> | ||
<!--T:139--> | |||
before running <code>apptainer</code>. | before running <code>apptainer</code>. | ||
</translate> | </translate> |