Singularity

[linkstandalone] Singularity

Singularity Containers

I recently was introduced to a new container technology called Singularity. If you are unfamiliar with containers, the short version is that they are like running a virtual machine without the high cost of running an entire operating system. That is a bit of a gross generalization, but this post isn’t about that. Do a little reading elsewhere to get caught up. It’s a pretty cool project geared towards folks in the HPC realm.

So What is it?

The project was born out of Lawrence Berkeley National Laboratory and has several interesting stated goals:

The main idea is that you can take a container which you have made and move it onto another system, and run it without issue. This tries to avoid the age old problem of “Well, it runs on my system!”. It’s interesting that this has been developed to work well with high performance computing architectures. So if you have a RedHat system with a legacy kernel, you can still run your Singularity container. Also I appreciate their security model as well. If you cannot get root access outside of the container, you cannot get root access inside of the container. Singularity also differs from Docker in other ways. For instance, if you need access to hardware resources such as a GPU, you can easily take advantage of that from within your container.

Setup:

The Ubuntu repositories have an outdated version, so I would recommend installing from source (GitHub). It worked painlessly for me. Run these commands to install:

$ git clone https://github.com/singularityware/singularity.git
$ cd singularity
$ ./autogen.sh
$ ./configure --prefix=/usr/local
$ make
$ sudo make install

Type singularity and you should see the help menu appear in your console.

Creating an image

We will set up a container that will be used to mine Monero. If you are unfamiliar with Monero, it is a cryptocurrency and you can read more about it here. First, we will need to create our recipe. This is the simple file I came up with. The format is a mix of shell script and their own syntax. (Name this file whatever you want. Mine is simply ./Singularity)

BootStrap: docker
From: ubuntu:latest
%runscript
%post
apt update && apt install -y git build-essential cmake libuv1-dev libmicrohttpd-dev
git clone https://github.com/xmrig/xmrig.git
mkdir /xmrig/build
cd /xmrig/build
cmake ..
make

What this is doing is simply going out and grabbing the base Ubuntu OS image from Docker, then installing the extra utilities which I need. To build this recipe, you can issue the command:

$ sudo singularity build ubuntu.simg Singularity

Running

Now you should have your ubuntu.simg file in your current directory. To get into your container, simply issue this command (Note: Your prompt should change if it worked correctly):

$ singularity shell ubuntu.img

Congratulations, you’re in business! You’re now inside of your very own Ubuntu Singularity container! We can now hop over to /xmrig/build and fire up our miner! For more information, head over to the Singularity documentation here.

[originally posted 2017]