{"id":75,"date":"2018-01-16T20:11:57","date_gmt":"2018-01-16T20:11:57","guid":{"rendered":"https:\/\/in.nau.edu\/hpc\/?page_id=75"},"modified":"2024-08-14T08:23:57","modified_gmt":"2024-08-14T15:23:57","slug":"containers","status":"publish","type":"page","link":"https:\/\/in.nau.edu\/arc\/overview\/containers\/","title":{"rendered":"Containers"},"content":{"rendered":"<!-- shortcode-right-column -->\n<div class=\"shortcode-right-column\" >\n    <div class=\"shortcode-right-column__container\"><\/p>\n<p><!-- shortcode-contact -->\n<div class=\"shortcode-contact\">\n    <div class=\"contact-header\">\n        <h3>Contact Advanced Research Computing<\/h3>\n    <\/div>\n    <div class=\"contact-body\">\n                <a href=\"mailto:ask-arc@nau.edu\" aria-label=\"Contact Advanced Research Computing: Email Address\" title=\"Email Address\">\n            <div class=\"contact-icon-container\">\n                <i class=\"fas fa-envelope\" aria-hidden=\"true\"><\/i>\n                <span class=\"sr-only\">Email:<\/span>\n            <\/div>\n            <div class=\"contact-email\">ask-arc&#8203;@nau.edu<\/div>\n        <\/a>\n                    <\/div>\n<\/div>\n\n<br \/>\n<\/div>\n<\/div>\n\n<h1>Containers<\/h1>\n<p>Using containers in Linux has become a common practice in many business environments. Using technologies like Docker or Kubernetes, it is possible to create self-contained environments or &#8220;containers&#8221; that are designed for a specific purpose. Unfortunately, the use of these technologies in HPC has been problematic due to security concerns. The open source project Singularity addresses this problem, allowing for the creation of containers that maintain the security infrastructure of the machine they are running on.<\/p>\n<p>Monsoon users now have access to Singularity, allowing them to run specific codes that were built in a container. Although Docker is not supported on Monsoon, Singularity can be used to import and convert Docker containers, allowing them to be run on Monsoon.<\/p>\n<h2>Basic Usage<\/h2>\n<p>You can download pre-made singularity images from the singularity hub website. In the following example, we will download and run a simple singularity image called <span style=\"font-size: 16px; font-family: monospace; border: 1px solid; border-radius: 4px; padding: 0px 4px 0px; border-color: #BBBBBB;\">singularity-hello-world<\/span>.<\/p>\n<pre><code>[abc123@wind ~]$ singularity pull shub:\/\/346\r\nFound image vsoch\/singularity-hello-world:master\r\nDownloading image... 928b4fc5dbe536cc8ba678eb5e37aca814d4d413.img.gz\r\nDecompressing \/home\/mkg52\/928b4fc5dbe536cc8ba678eb5e37aca814d4d413.img.gz\r\n[abc123@wind ~]$ mv 928b4fc5dbe536cc8ba678eb5e37aca814d4d413.img hello.img\r\n[abc123@wind ~]$ singularity run hello.img\r\nHello\r\n[abc123@wind ~]$ singularity run hello.img from inside docker\r\nHello from inside docker<\/code><\/pre>\n<p>More examples can be found on the web.<\/p>\n<h2>Running Singularity with Slurm<\/h2>\n<p>Any Singularity image can also be used with Slurm to run jobs. Using the image downloaded in the previous example, we could submit a job array and pass the current array id number as a parameter to the Singularity container (see <a href=\"https:\/\/in.nau.edu\/arc\/overview\/using-the-cluster-advanced\/job-arrays\/\">Job Arrays<\/a> for more information). This is shown in the following code snippet:<\/p>\n<pre><code>#!\/bin\/bash\r\n#SBATCH --job-name=singularity-test\r\n#SBATCH --array=1-5\r\n\r\nmodule load singularity\r\nsrun singularity run hello.img \"$SLURM_ARRAY_TASK_ID\"<\/code><\/pre>\n<p>Submitting the job and checking the output files shows that the &#8220;Hello&#8221; command was run with the inputs 1 through 5:<\/p>\n<pre><code>[abc123@wind ~]$ sbatch singularity_test.sh\r\nSubmitted batch job 320\r\n[abc123@wind ~]$ ls slurm-*\r\nslurm-320_1.out slurm-320_2.out slurm-320_3.out slurm-320_4.out slurm-320_5.out\r\n[abc123@wind ~]$ cat slurm-*\r\nHello 1\r\nHello 2\r\nHello 3\r\nHello 4\r\nHello 5<\/code><\/pre>\n<p>If you require mpi support in your Singularity image, please note that the image must be specifically built with this functionality.<\/p>\n<h2>Converting Docker Images to Singularity Images<\/h2>\n<p>Singularity images cannot be created from scratch on Monsoon without root user permissions.<\/p>\n<ul>\n<li>If you need a docker image converted, there are two options available to you:<\/li>\n<\/ul>\n<ol>\n<li>Ask the staff to create one for you or <a href=\"https:\/\/in.nau.edu\/arc\/contact-us\/\">contact us<\/a>.<\/li>\n<li>Convert the docker image on your own machine and then upload it to Monsoon.<\/li>\n<\/ol>\n<p>In the event you should choose option 2, please follow these instructions:<br \/>\n<strong>The following must be done on your personal computer,\u00a0not\u00a0Monsoon:<\/strong><\/p>\n<ol>\n<li>Install Singularity using their\u00a0<a href=\"http:\/\/singularity.lbl.gov\/all-releases\">instructions<\/a>.\u00a0<strong>IMPORTANT!\u00a0<\/strong>Singularity is designed for Unix-based systems, so you must have access to either a Mac OSX or Linux system to install Singularity. The following instructions will assume a Linux operating system.<\/li>\n<li>Download and convert a docker image from Docker&#8217;s repository: Singularity allows you to create an image and then import\/convert a Docker image from Docker&#8217;s online repository. For example, to create a Singularity image of 2GB and import\/convert Docker&#8217;s latest Ubuntu image into the Singularity image you would do the following (you must be the root user):<\/li>\n<\/ol>\n<pre><code>[root@head images]# singularity create -s 2048 MyUbuntu.img\r\nCreating a new image with a maximum size of 2048MiB...\r\nExecuting image create helper\r\nFormatting image with ext3 file system\r\nDone.\r\n[root@head images]# ls\r\nMyUbuntu.img\r\n[root@head images]# singularity import MyUbuntu.img docker:\/\/ubuntu:latest\r\nCache folder set to \/root\/.singularity\/docker\r\n[[ Extraction output ommitted ]]\r\nBootstrap initialization\r\nNo bootstrap definition passed, updating container\r\nExecuting Prebootstrap module\r\nExecuting Postbootstrap module\r\nDone.\r\n[root@head images]# singularity exec MyUbuntu.img cat \/etc\/issue\r\nUbuntu 16.04.2 LTS \\n \\l\r\n[root@head images]# Hello<\/code><\/pre>\n<p>You can see that the version of Ubuntu is displayed when we run this command note. You can browse available docker images on\u00a0<a href=\"https:\/\/hub.docker.com\/explore\/\">Docker&#8217;s Repository<\/a>.<\/p>\n<p>3. <a href=\"https:\/\/in.nau.edu\/arc\/overview\/file-management\/\">Upload your Singularity image to monsoon<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Containers Using containers in Linux has become a common practice in many business environments. Using technologies like Docker or Kubernetes, it is possible to create self-contained environments or &#8220;containers&#8221; that are designed for a specific purpose. Unfortunately, the use of these technologies in HPC has been problematic due to security concerns. The open source project [&hellip;]<\/p>\n","protected":false},"author":76,"featured_media":145,"parent":49,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","ring_central_script_selection":"","footnotes":""},"class_list":["post-75","page","type-page","status-publish","has-post-thumbnail","hentry"],"_links":{"self":[{"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages\/75","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/users\/76"}],"replies":[{"embeddable":true,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/comments?post=75"}],"version-history":[{"count":6,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages\/75\/revisions"}],"predecessor-version":[{"id":3596,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages\/75\/revisions\/3596"}],"up":[{"embeddable":true,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages\/49"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/media\/145"}],"wp:attachment":[{"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/media?parent=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}