{"id":11139,"date":"2025-07-28T22:31:13","date_gmt":"2025-07-29T02:31:13","guid":{"rendered":"https:\/\/labs.icahn.mssm.edu\/minervalab\/?page_id=11139"},"modified":"2026-02-14T00:52:49","modified_gmt":"2026-02-14T05:52:49","slug":"running-container-apptainer-singularity","status":"publish","type":"page","link":"https:\/\/labs.icahn.mssm.edu\/minervalab\/documentation\/running-container-apptainer-singularity\/","title":{"rendered":"Running Container: Apptainer\/Singularity"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; fullwidth=&#8221;on&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_fullwidth_menu menu_id=&#8221;15&#8243; menu_style=&#8221;centered&#8221; fullwidth_menu=&#8221;on&#8221; active_link_color=&#8221;#d80b8c&#8221; dropdown_menu_line_color=&#8221;#221f72&#8243; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; menu_font=&#8221;|600|||||||&#8221; menu_text_color=&#8221;#FFFFFF&#8221; menu_font_size=&#8221;16px&#8221; background_color=&#8221;#221f72&#8243; background_layout=&#8221;dark&#8221; sticky_position=&#8221;top&#8221; global_colors_info=&#8221;{}&#8221;][\/et_pb_fullwidth_menu][\/et_pb_section][et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;4.16&#8243; custom_padding=&#8221;0px||0px||false|false&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_row _builder_version=&#8221;4.16&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; custom_padding=&#8221;||3px||false|false&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.16&#8243; custom_padding=&#8221;|||&#8221; global_colors_info=&#8221;{}&#8221; custom_padding__hover=&#8221;|||&#8221;][et_pb_text admin_label=&#8221;Breadcrumb&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; custom_padding=&#8221;||0px|||&#8221; global_colors_info=&#8221;{}&#8221;]<\/p>\n<p><a href=\"https:\/\/labs.icahn.mssm.edu\/minervalab\/scientific-computing-and-data\/\">Scientific Computing and Data<\/a> \/ <a href=\"https:\/\/labs.icahn.mssm.edu\/minervalab\/\">High Performance Computing<\/a> \/ <a title=\"Documentation\" href=\"https:\/\/labs.icahn.mssm.edu\/minervalab\/documentation\/\">Documentation<\/a> \/ Running Container: Apptainer\/Singularity<\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section][et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_row _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_text admin_label=&#8221;Introduction&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; header_font=&#8221;|600|||||||&#8221; header_text_color=&#8221;#221f72&#8243; header_font_size=&#8221;26px&#8221; header_2_text_color=&#8221;#221f72&#8243; header_2_font_size=&#8221;24px&#8221; custom_margin=&#8221;10px||20px||false|false&#8221; custom_padding=&#8221;10px||20px||false|false&#8221; global_colors_info=&#8221;{}&#8221;]<\/p>\n<h1>Apptainer\/Singularity<\/h1>\n<p>&nbsp;<\/p>\n<p>On the Minerva HPC cluster, Apptainer (formerly known as Singularity) is the supported container runtime environment, known for its compatibility with high-performance computing (HPC) systems and enhanced security model. Unlike Docker, which requires root privileges and runs persistent daemons\u2014posing potential security risks on multi-user HPC clusters\u2014Apptainer was designed from the ground up to support secure, non-privileged container execution.<\/p>\n<p>Although Docker is not available directly on Minerva for these reasons, existing Docker container images can be seamlessly converted and executed using Apptainer. This compatibility allows users to leverage the vast ecosystem of Docker containers while adhering to the stricter security and user access controls required on shared compute infrastructure.<\/p>\n<p>Apptainer enables you to create and execute containers that encapsulate complex software environments into a single portable and reproducible image file (typically with a <code>.sif<\/code> extension). These images are self-contained, making them ideal for consistent and repeatable workflows across different environments.<\/p>\n<p data-start=\"1425\" data-end=\"1469\">You may choose to use Apptainer on Minerva when:<\/p>\n<ul data-start=\"1470\" data-end=\"1877\">\n<li data-start=\"1470\" data-end=\"1604\">\n<p data-start=\"1472\" data-end=\"1604\">The software you need has complex dependencies that are difficult or impossible to install on your local machine or the HPC cluster.<\/p>\n<\/li>\n<li data-start=\"1605\" data-end=\"1737\">\n<p data-start=\"1607\" data-end=\"1737\">The application requires newer kernel versions or system-level libraries that are not supported by the cluster\u2019s operating system.<\/p>\n<\/li>\n<li data-start=\"1738\" data-end=\"1877\">\n<p data-start=\"1740\" data-end=\"1877\">You need to reproduce a past analysis, share workflows with collaborators, or maintain long-term reproducibility of scientific pipelines.<\/p>\n<\/li>\n<\/ul>\n<p>[\/et_pb_text][et_pb_text admin_label=&#8221;How to use apptainer on Minerva&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; header_font=&#8221;|600|||||||&#8221; header_text_color=&#8221;#221f72&#8243; header_font_size=&#8221;26px&#8221; header_2_text_color=&#8221;#221f72&#8243; header_2_font_size=&#8221;24px&#8221; custom_margin=&#8221;10px||20px||false|false&#8221; custom_padding=&#8221;10px||||false|false&#8221; global_colors_info=&#8221;{}&#8221;]<\/p>\n<h2>Apptainer\/Singularity Modules on Minerva HPC<\/h2>\n<p>Search for available Apptainer and Singularity Modules on Minerva:<\/p>\n<p><code><a href=\"https:\/\/labs.icahn.mssm.edu\/minervalab\/documentation\/r\/\"><strong><\/strong><\/a><\/code><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/scpublic.dmz.hpc.mssm.edu\/HPC\/apptainer\/ml_av_apptainer.png&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; width=&#8221;60%&#8221; max_width=&#8221;60%&#8221; module_alignment=&#8221;center&#8221; global_colors_info=&#8221;{}&#8221;][\/et_pb_image][et_pb_image src=&#8221;https:\/\/scpublic.dmz.hpc.mssm.edu\/HPC\/apptainer\/ml_av_singularity.png&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; width=&#8221;60%&#8221; max_width=&#8221;60%&#8221; module_alignment=&#8221;center&#8221; custom_margin=&#8221;||10px||false|false&#8221; custom_padding=&#8221;||10px||false|false&#8221; global_colors_info=&#8221;{}&#8221;][\/et_pb_image][et_pb_text admin_label=&#8221;How to use apptainer on Minerva&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; header_font=&#8221;|600|||||||&#8221; header_text_color=&#8221;#221f72&#8243; header_font_size=&#8221;26px&#8221; header_2_text_color=&#8221;#221f72&#8243; header_2_font_size=&#8221;24px&#8221; custom_margin=&#8221;10px||20px||false|false&#8221; custom_padding=&#8221;10px||20px||false|false&#8221; hover_enabled=&#8221;0&#8243; global_colors_info=&#8221;{}&#8221; sticky_enabled=&#8221;0&#8243;]<\/p>\n<h2>How to use Apptainer\/Singularity on Minerva HPC<\/h2>\n<p>Since Singularity and Apptainer share nearly identical command-line interfaces, the following sections will exclusively refer to Apptainer for consistency, but these commands are compatible with Singularity.\u00a0<\/p>\n<p>Load the apptainer module:<\/p>\n<pre><code>$ module load apptainer\/1.3.6<\/code><\/pre>\n<p>You can use \u201capptainer pull\u201d to download a container image from a give URI, such as pull the image from Sylabs Cloud library:\/\/, Singularity Hub shub:\/\/ and Docker Hub docker:\/\/<\/p>\n<pre><code>$ apptainer pull --name hello-world_latest.sif shub:\/\/vsoch\/hello-world<\/code><\/pre>\n<p>To pull a docker image:<\/p>\n<pre><code>$ apptainer pull ubuntu_latest.sif docker:\/\/ubuntu:latest<\/code><\/pre>\n<p>To create a container within a writable directory (called a sandbox):<\/p>\n<pre><code>$ apptainer build --sandbox lolcow\/ shub:\/\/GodloveD\/lolcow<\/code><\/pre>\n<p><code><a href=\"https:\/\/labs.icahn.mssm.edu\/minervalab\/documentation\/r\/\"><strong><\/strong><\/a><\/code><\/p>\n<p>[\/et_pb_text][et_pb_text admin_label=&#8221;Running an Apptainer Container on Minerva&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; header_font=&#8221;|600|||||||&#8221; header_text_color=&#8221;#221f72&#8243; header_font_size=&#8221;26px&#8221; header_2_text_color=&#8221;#221f72&#8243; header_2_font_size=&#8221;24px&#8221; custom_margin=&#8221;10px||20px||false|false&#8221; custom_padding=&#8221;10px||20px||false|false&#8221; global_colors_info=&#8221;{}&#8221;]<\/p>\n<h2>Running an Apptainer Container<\/h2>\n<p>When running within an Apptainer container, a user has the same permissions and privileges that he or she would have outside the container.<\/p>\n<p>Once you have the images, you can shell into it (The shell subcommand is useful for interactive work)<\/p>\n<pre><code># From the cluster\r\n$ apptainer shell ubuntu_latest.sif<\/code><\/pre>\n<p>To run a container with the default runscript command:<\/p>\n<pre><code>$ apptainer run hello-world_latest.sif<\/code><\/pre>\n<p>Or run a custom command with exec, or pipes for batch processing (e.g. within a LSF job), For example:<\/p>\n<pre><code>$ apptainer exec ubuntu_latest.sif \/path\/to\/my\/script.sh<\/code><\/pre>\n<p>Where <code>script.sh<\/code> contains the processing steps to be executed within the LSF batch job. Alternatively, you can pass any standard Linux command directly to the <code>exec<\/code> subcommand. The <code>exec<\/code> subcommand also supports features like pipes and output redirection. Below is a simple example demonstrating a change in the Linux distribution environment:<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/scpublic.dmz.hpc.mssm.edu\/HPC\/apptainer\/apptainer_os.png&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; width=&#8221;60%&#8221; max_width=&#8221;60%&#8221; module_alignment=&#8221;center&#8221; custom_margin=&#8221;||20px||false|false&#8221; custom_padding=&#8221;||20px||false|false&#8221; global_colors_info=&#8221;{}&#8221;][\/et_pb_image][et_pb_text admin_label=&#8221;Building External Directories&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; header_font=&#8221;|600|||||||&#8221; header_text_color=&#8221;#221f72&#8243; header_font_size=&#8221;26px&#8221; header_2_text_color=&#8221;#221f72&#8243; header_2_font_size=&#8221;24px&#8221; custom_margin=&#8221;10px||20px||false|false&#8221; custom_padding=&#8221;10px||20px||false|false&#8221; global_colors_info=&#8221;{}&#8221;]<\/p>\n<h2>Building External Directories<\/h2>\n<p>Binding a directory to your Apptainer container allows you to access files in a host system directory from within your container.<\/p>\n<p>By default, \u00a0<code>\/tmp<\/code>, current working directory <code>$PWD<\/code>, user home directory <code>$HOME<\/code>, and <code>\/sc\/arion\/\u00a0<\/code><span style=\"font-size: 14px\">is automatically mounted into an Apptainer container, which should be enough for most of the cases. You can also bind other directories into your Apptainer container yourself. To get a shell with a specified &#8216;dir&#8217; mounted in the image.<\/span><\/p>\n<blockquote>\n<pre><code>$ apptainer run -B \/user\/specified\/dir ubuntu_latest.sif<\/code><\/pre>\n<\/blockquote>\n<p>Warning: Sometimes libraries or packages in\u00a0<code>$HOME <\/code>got picked up in container, especially for python packages at <code>~\/.local <\/code>and <code>R library $_LIBS_USER at ~\/.Rlib)<\/code>.[\/et_pb_text][et_pb_text admin_label=&#8221;Running GPU-enabled containers&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; header_font=&#8221;|600|||||||&#8221; header_text_color=&#8221;#221f72&#8243; header_font_size=&#8221;26px&#8221; header_2_text_color=&#8221;#221f72&#8243; header_2_font_size=&#8221;24px&#8221; custom_margin=&#8221;10px||20px||false|false&#8221; custom_padding=&#8221;10px||20px||false|false&#8221; global_colors_info=&#8221;{}&#8221;]<\/p>\n<h2>Running GPU-Enabled Containers<\/h2>\n<p>Apptainer supports running on GPUs from within containers. The\u00a0<code>--nv\u00a0<\/code>option must be passed to the exec or shell subcommand. For example:<\/p>\n<blockquote>\n<pre><code>$ module load apptainer\/1.3.6 \r\n$ apptainer pull docker:\/\/tensorflow\/tensorflow:latest-gpu \r\n$ apptainer shell --nv -B \/run tensorflow_latest-gpu-jupyter.sif<\/code><\/pre>\n<\/blockquote>\n<p><b>IMPORTANT:<\/b><br \/>Apptainer gives you the ability to install and run applications in your own Linux environment with your own customized software stack. While the HPC staff can provide guidance on how to create and use Apptainer containers, we do not have the resources to manage containers for individual users. If you decide to use Apptainer, it is your responsibility to build and manage your own containers, and software within your own Linux environment.<\/p>\n<p>[\/et_pb_text][et_pb_text admin_label=&#8221;Build your own containers&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; header_font=&#8221;|600|||||||&#8221; header_text_color=&#8221;#221f72&#8243; header_font_size=&#8221;26px&#8221; header_2_text_color=&#8221;#221f72&#8243; header_2_font_size=&#8221;24px&#8221; custom_margin=&#8221;10px||20px||false|false&#8221; custom_padding=&#8221;10px||20px||false|false&#8221; global_colors_info=&#8221;{}&#8221;]<\/p>\n<h2>Building Your Own Containers<\/h2>\n<p>Although there are a lot of container images contributed by various users on Docker Hub and Singularity Hub, there is time that you want to create\/build your own containers. You can build your own container images either use Singularity <a href=\"https:\/\/cloud.sylabs.io\/builder\">Remote Builder<\/a> or your local Linux workstation with which you have the root access. If you don&#8217;t have a Linux system you could easily install one in a virtual machine using software like <a href=\"https:\/\/www.virtualbox.org\/\">VirtualBox<\/a>, <a href=\"https:\/\/www.vagrantup.com\/\">Vagrant<\/a>, <a href=\"http:\/\/www.vmware.com\/\">VMware<\/a>, or <a href=\"http:\/\/www.parallels.com\/\">Parallels<\/a>.<\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li>Apptainer build is not fully supported on Minerva due to the <code>sudo<\/code> privileges for users<\/li>\n<li>Using the Remote Builder, you can easily and securely create containers for your applications without special privileges or set up in your local environment from a Linux machine where you have administrative access (i.e. a personal machine)<\/li>\n<li>Write your recipe file\/definition file following <a href=\"https:\/\/sylabs.io\/guides\/3.6\/user-guide\/definition_files.html\">the guide<\/a>. You can easily find some examples for recipe files online, for example <a href=\"https:\/\/github.com\/NIH-HPC\/singularity-def-files\">this GitHub repo<\/a>.<\/li>\n<li>Convert a Dockerfile into a Singularity (now Apptainer) recipe file using spython \u2014 a Python-based tool to work with Singularity\/Apptainer images and recipes.:<br \/>\n<blockquote>\n<pre><code>$ ml python \r\n$ spython recipe Dockerfile Singularity<\/code><\/pre>\n<\/blockquote>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>[\/et_pb_text][et_pb_text admin_label=&#8221;Useful Links&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; header_font=&#8221;|600|||||||&#8221; header_text_color=&#8221;#221f72&#8243; header_font_size=&#8221;26px&#8221; header_2_text_color=&#8221;#221f72&#8243; header_2_font_size=&#8221;24px&#8221; custom_margin=&#8221;10px||20px||false|false&#8221; custom_padding=&#8221;10px||20px||false|false&#8221; global_colors_info=&#8221;{}&#8221;]<\/p>\n<h2>Some Helpful External Web Sites<\/h2>\n<ul>\n<li><a href=\"https:\/\/sylabs.io\/guides\/3.6\/user-guide\/\">Singularity User guide<\/a><\/li>\n<li><a href=\"https:\/\/singularity-hub.org\/\">Singularity Hub<\/a><\/li>\n<li><a href=\"https:\/\/hub.docker.com\/\">Docker Hub<\/a><\/li>\n<li><a href=\"https:\/\/cloud.sylabs.io\/builder\">Remote Builder<\/a><\/li>\n<\/ul>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Scientific Computing and Data \/ High Performance Computing \/ Documentation \/ Running Container: Apptainer\/SingularityApptainer\/Singularity &nbsp; On the Minerva HPC cluster, Apptainer (formerly known as Singularity) is the supported container runtime environment, known for its compatibility with high-performance computing (HPC) systems and enhanced security model. Unlike Docker, which requires root privileges and runs persistent daemons\u2014posing potential [&hellip;]<\/p>\n","protected":false},"author":624,"featured_media":0,"parent":35,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"class_list":["post-11139","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/pages\/11139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/users\/624"}],"replies":[{"embeddable":true,"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/comments?post=11139"}],"version-history":[{"count":12,"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/pages\/11139\/revisions"}],"predecessor-version":[{"id":13298,"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/pages\/11139\/revisions\/13298"}],"up":[{"embeddable":true,"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/pages\/35"}],"wp:attachment":[{"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/media?parent=11139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}