AWS, Cloud Computing, Kubernetes

5 Mins Read

Singularity: Container Runtime for Research and Scientific Workloads

Introduction

A container runtime is a software component for launching and managing containers within a containerization platform, such as Docker or Kubernetes. It provides the necessary environment and resources for containers to run isolated and securely on a host machine. The container runtime interacts with the host operating system’s kernel to create lightweight, isolated environments known as containers. It manages the lifecycle of containers, including creating, starting, stopping, and deleting them. The runtime also handles containerization’s resource allocation, networking, storage, and security aspects.

Singularity

Singularity is an open-source container runtime designed primarily for high-performance computing (HPC) and scientific computing environments. Unlike traditional container runtimes, Singularity focuses on providing containerization capabilities while maintaining compatibility with the host system, especially regarding accessing system resources and privileges.

Singularity was developed to address the needs of researchers and scientists who often require running complex simulations or analysis tools on HPC clusters. Some of the key features and characteristics of Singularity include:

  1. Compatibility: Singularity containers are designed to be compatible with the host operating system. This means that users can run Singularity containers directly on the host without requiring elevated privileges or modifications to the host system.
  2. User-driven: Singularity enables users to create, manage, and distribute their containers without requiring administrative privileges. This allows researchers to encapsulate their scientific workflows and share them easily with collaborators.
  3. Security: Singularity emphasizes security by providing a strong isolation boundary between the container and the host system. It utilizes user namespaces and other Linux kernel features to ensure that the containerized application cannot access or modify resources outside the container.
  4. High-performance computing: Singularity is optimized for HPC environments, supporting technologies such as InfiniBand and MPI (Message Passing Interface). It allows researchers to take advantage of the performance capabilities of HPC clusters without sacrificing containerization benefits.

Singularity containers use the “.sif” file format, a compressed file containing the necessary files and metadata for the container. Users can create Singularity containers from scratch or convert existing Docker or OCI (Open Container Initiative) containers into Singularity format.

Steps to Install Singularity Installation on Linux

Containers are predominantly supported on Linux due to the kernel features such as namespaces that facilitate their functionality. To install Singularity on either a bare metal Linux system or a Linux virtual machine (VM), you can follow the steps outlined below:

Setting-up VM:

In the AWS Account and go to the Amazon EC2 instances section.

Choose Launch Instances

step1

Select the OS of your choice, here AmazonLinux has chosen.

step2

Select the instance type and keypair.

step3

Select the Create Security Group and keep the default rules as shown below, or you can select the existing SG if you already have the same rules. After that, click on Launch Instances.

step4

After the successful creation of the Instance, you will get the landing page and copy the public Ip from there:

step5

Connect to the instance and follow the procedure mentioned below.

step6

step7

Installation of singularity:

If you already have a previous version of Singularity installed, removing it before proceeding with the installation commands is recommended. To install Singularity from a source, you must have certain development tools installed on your system. In case you encounter any missing dependencies during the installation process, you can try installing them using the following method:

step8

Install a specific release

The commands below will install the release from the available GitHub releases to /usr/local.

step9

step10

Building an Image Using the Singularity:

Downloading an existing container from Docker Hub

The “build” command in Singularity allows you to fetch layers from Docker Hub and construct Singularity containers by assembling these layers. This process enables you to utilize pre-existing Docker images and convert them into Singularity containers. By leveraging the “build” command, Singularity simplifies the creation of containers by leveraging the extensive library of Docker images available on Docker Hub.

step11

Building containers from Singularity recipe files

Singularity recipe files can generally be used as targets while building containers. For any information needed while writing Singularity recipe files, refer to the Container Recipes docs.  For example, let’s consider having the container recipe file called xingsing, as shown below, and for building a container by using it:

step12

You can do so with the following command.

step13

Conclusion

Singularity is a powerful container runtime for Linux that offers various benefits and use cases in research computing, scientific simulations, HPC, bioinformatics, machine learning, and more. When setting up Singularity on a Linux system, it is important to consider the following key points:

  • Compatibility: Singularity is primarily designed to run on Linux, and leverages kernel features such as namespaces to support containers effectively.
  • Singularity Recipe Files: Singularity recipe files allow you to define the construction process of containers, including the base image, software dependencies, environment variables, and execution commands. These recipe files can be used to build containers or customize existing ones.

Drop a query if you have any questions regarding Singularity and I will get back to you quickly.

Making IT Networks Enterprise-ready – Cloud Management Services

  • Accelerated cloud migration
  • End-to-end view of the cloud environment
Get Started

About CloudThat

CloudThat is an official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft Gold Partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.

To get started, go through our Consultancy page and Managed Services Package that is CloudThat’s offerings.

FAQs

1. Can Singularity run Docker containers?

ANS: – Yes, Singularity can run Docker containers. It has built-in support for importing and running Docker images, making it easy to leverage the extensive Docker image ecosystem within the Singularity runtime.

2. Can Singularity containers run on different Linux distributions?

ANS: – Yes, Singularity containers are designed to be highly portable and can run on different Linux distributions without modification. This is achieved by utilizing the host system’s kernel and namespaces, allowing Singularity containers to work seamlessly across various distributions.

WRITTEN BY Bhanu Prakash K

K Bhanu Prakash is working as a Subject Matter Expert in CloudThat. He is proficient in Managing and configuring AWS Infrastructure as well as on Kubernetes and DevOps tools like Terraform, ansible, Jenkins, and Git. He is very keen on learning new technologies and publishing blogs for the tech community.

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!