{"id":112638,"date":"2018-02-07T16:25:47","date_gmt":"2018-02-07T21:25:47","guid":{"rendered":"http:\/\/www.bu.edu\/tech\/?page_id=112638"},"modified":"2026-11-09T13:02:16","modified_gmt":"2026-11-09T18:02:16","slug":"singularity","status":"publish","type":"page","link":"https:\/\/www.bu.edu\/tech\/support\/research\/software-and-programming\/containers\/singularity\/","title":{"rendered":"Using Singularity\/Apptainer"},"content":{"rendered":"<p><a name=\"top\"><\/a><\/p>\n<div style=\"width: 85%;\">\n<div style=\"float: right; width: 40%;\"><img loading=\"lazy\" src=\"\/tech\/files\/2024\/01\/singularity-e1706624540369.png\" alt=\"\" width=\"293\" height=\"151\" class=\"alignnone size-full wp-image-150145\" \/><\/div>\n<div style=\"float: none;\">\n<p><strong>Sections<\/strong><\/p>\n<ul>\n<li><a href=\"#command\">Singularity\/Apptainer on the SCC<\/a><\/li>\n<li><a href=\"#vs\">Singularity vs Apptainer<\/a><\/li>\n<li><a href=\"#wrap\">Wrapper for Singularity\/Apptainer<\/a><\/li>\n<li><a href=\"#interactive\">Interactive Usage<\/a><\/li>\n<li><a href=\"#batch\">Batch\u00a0Usage<\/a><\/li>\n<\/ul>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<h2><a name=\"command\"><\/a>Singularity\/Apptainer on the SCC<\/h2>\n<p>The main command for using singularity\/apptainer is <code>\/usr\/bin\/apptainer<\/code> and can be called directly with either <code><span class=\"command\">apptainer<\/span><\/code> or <code><span class=\"command\">singularity<\/span><\/code>. Please refer to the Singularity\/Apptainer documentation at <a href=\"https:\/\/apptainer.org\/documentation\/\"> https:\/\/apptainer.org\/documentation\/<\/a> for general use information.<\/p>\n<h2><a name=\"vs\"><\/a>Singularity vs Apptainer<\/h2>\n<p>Singularity recently underwent a name change to Apptainer. It is the same project as Singularity and Apptainer maintains backwards compatibility with Singularity.<\/p>\n<p>The changes include:<\/p>\n<ul>\n<li>the command line interface changed from <code><span class=\"command\">singularity<\/span><\/code> &#8211;&gt; <code><span class=\"command\">apptainer<\/span><\/code>.<\/li>\n<li>you now define environmental variables for your container by prepending <code><span class=\"command\">APPTAINERENV_<\/span><\/code> instead of <code><span class=\"command\">SINGULARITYENV_<\/span><\/code>. If you use the old <code><span class=\"command\">SINGULARITYENV_<\/span><\/code> syntax, you will be presented with a warning.<\/li>\n<li>User configurations are now stored in <code><span class=\"command\">~\/.apptainer<\/span><\/code> instead of in <code><span class=\"command\">~\/.singularity<\/span><\/code>.<\/li>\n<\/ul>\n<p>Please refer to this webpage for more extensive documentation on the singularity &#8211;&gt; apptainer change: <a href=\"https:\/\/apptainer.org\/docs\/user\/latest\/singularity_compatibility.html\"> https:\/\/apptainer.org\/docs\/user\/latest\/singularity_compatibility.html<\/a><\/p>\n<h2><a name=\"wrap\"><\/a>Wrapper for Singularity\/Apptainer<\/h2>\n<p>In order to facilitate integration with the SCC, we provide a command wrapper <code><span class=\"command\">scc-singularity<\/span><\/code>:<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">scc-singularity run my_container.sif<\/span><\/code><\/pre>\n<p>The wrapper is available on the PATH for general use and provides the following features:<\/p>\n<ol>\n<li>Automatically binds:\n<ul>\n<li>user&#8217;s home directory<\/li>\n<li>user&#8217;s project spaces<\/li>\n<li>the node(s) <code>\/scratch<\/code><\/li>\n<li><code>\/usr\/local<\/code><\/li>\n<li><code>\/share<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Preserves and passes into the container SCC environment variables:\n<ul>\n<li><code>DISPLAY<\/code><\/li>\n<li><code>NSLOTS<\/code><\/li>\n<li><code>TMPDIR<\/code><\/li>\n<li><code>USER<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Will detect if using GPU(s) and pass <code>CUDA_VISIBLE_DEVICES<\/code> into the container.<\/li>\n<\/ol>\n<p>If the container has code installed into its own <code>\/usr\/local<\/code> directory, then pass the <code>--nolocal<\/code> flag to scc-singularity:<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">scc-singularity --nolocal run my_container.sif<\/span><\/code><\/pre>\n<p>The <code>--scc-preview<\/code> and <code>--scc-debug<\/code> commands can be used to print out the command executed by the <code>scc-singularity<\/code> wrapper:<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">scc-singularity --scc-preview run my_container.sif<\/span>\r\n\/usr\/bin\/singularity run -e  -B \/share -B \/usr1 -B \/usr2 -B \/usr3 -B \/usr4 -B \/var\/spool\/sge -B \/project -B \/projectnb -B \/projectnb2 -B \/scratch -B \/net -B \/ad -B \/usr\/local -B \/var\/lib\/dbus\/machine-id my_container.sif\r\npreview mode - command not executed\r\n<\/code><\/pre>\n<h2><a name=\"interactive\"><\/a>Interactive Usage<\/h2>\n<p>Singularity can be used to run a shell interactively inside a container. This is accomplished using the <code><span class=\"command\">shell<\/span><\/code> subcommand. To try these commands, first get a copy of a container running the Debian 11 operating system from the Sylabs container library. This will create a container file called <code><b>debian_11.sif<\/b><\/code>:<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">apptainer pull library:\/\/debian:11<\/span><\/code><\/pre>\n<p>Now try to run the container:<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">apptainer shell<\/span> <span class=\"placeholder\">debian_11.sif<\/span>\r\n<span class=\"prompt\">Apptainer&gt;<\/span> <span class=\"command\">grep<\/span> <span class=\"placeholder\">PRETTY_NAME \/etc\/os-release<\/span>\r\nPRETTY_NAME=\"Debian GNU\/Linux 11 (bullseye)\"<\/code><\/pre>\n<p>It is important to note that standard &#8220;shell&#8221; mode will not provide full environment settings required to interact with modules and other SCC provided features.<\/p>\n<p>The <code><span class=\"command\">scc-singularity<\/span><\/code> command has an additional subcommand <code><span class=\"command\">myshell<\/span><\/code> which invokes your default login shell with your complete login environment.<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">scc-singularity myshell<\/span> <span class=\"placeholder\">debian_11.sif<\/span><\/code><\/pre>\n<p>&nbsp;<\/p>\n<h2><a name=\"batch\"><\/a>Batch Usage<\/h2>\n<p>There are two main subcommands for running Singularity in batch: <code><span class=\"command\">exec<\/span><\/code> and <code><span class=\"command\">run<\/span><\/code>.<\/p>\n<ul>\n<li>Use the <code><span class=\"command\">exec<\/span><\/code> subcommand to execute the specified command within the container.\n<pre><code class=\"code-block\">#!\/bin\/bash -l\r\n#$ -P proj_name\r\n#$ -N singularity_exec\r\n#$ -j y\r\n# Run the container and execute a command within it.\r\nscc-singularity exec debian_11.sif grep PRETTY_NAME \/etc\/os-release <\/code><\/pre>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li>Use the <code><span class=\"command\">run<\/span><\/code> subcommand to run the command that the container is pre-configured to run.\n<pre><code class=\"code-block\">#!\/bin\/bash -l\r\n#$ -P proj_name\r\n#$ -N singularity_run\r\n#$ -j y\r\n# Run the container and run its preconfigured command.\r\nscc-singularity run debian_11.sif<\/code><\/pre>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Sections Singularity\/Apptainer on the SCC Singularity vs Apptainer Wrapper for Singularity\/Apptainer Interactive Usage Batch\u00a0Usage &nbsp; Singularity\/Apptainer on the SCC The main command for using singularity\/apptainer is \/usr\/bin\/apptainer and can be called directly with either apptainer or singularity. Please refer to the Singularity\/Apptainer documentation at https:\/\/apptainer.org\/documentation\/ for general use information. Singularity vs Apptainer Singularity recently underwent&#8230;<\/p>\n","protected":false},"author":3593,"featured_media":0,"parent":112635,"menu_order":1,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/112638"}],"collection":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/users\/3593"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/comments?post=112638"}],"version-history":[{"count":29,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/112638\/revisions"}],"predecessor-version":[{"id":163867,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/112638\/revisions\/163867"}],"up":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/112635"}],"wp:attachment":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/media?parent=112638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}