Create an Image | Singularity

Posted: May 9, 2021 at 11:13 am

A Singularity image, which can be referred to as a container, is a single file that contains a virtual file system. After creating an image you can install an operating system, applications, and save meta-data with it.

Whereas Docker assembles images from layers that are stored on your computer (viewed with the docker -ps command), a Singularity image is just one file that can sit on your Desktop, in a folder on your cluster, or anywhere.

Having Singularity containers housed within a single image file greatly simplifies management tasks such as sharing, copying, and branching your containers. It also means that standard Linux file system concepts like permissions, ownership, and ACLs apply to the container (e.g. I can give read only access to a colleague, or block access completely with a simple chmod command).

Singularity will create a default container image of 768MiB using the following command:

How big is it?

We can now use ls to list details about the image.

Note the permissions of the image make it executable. Singularity images can be executed directly.

You can change the maximum size of an image you create using the --size option. Note that --size is not a global option. It is an option to the create sub-command and must therefore follow it:

If you have already created an image and wish to overwrite it, you can do so with the --force option. This option must also follow the create sub-command.

Show Video Tutorial

You can increase the size of an image after it has been instantiated by using the expand Singularity sub-command as follows:

Similar to the create sub-command, you can override the default size increase (which is 768MiB) by using the --size option.

Show Video Tutorial

Once an image has been created and an OS has been added with the import or bootstrap commands, you can use the shell command to start an interactive shell within the container. But this is not possible when an image does not yet contain a functional OS or shell. For debugging, development, or simply inspecting an image that lacks a functional shell you can use the mount command like so:

Show Video Tutorial

At this point the image just contains a bare file system because we havent used something like the bootstrap or import commands to install an OS.

Singularity mounts images in private name-spaces so that the mount is only visible and accessible from within the freshly spawned shell. When you are finished, you can simply exit the shell and the file system will be automatically unmounted.

Files can be copied from the image to the host when it is mounted in this way, but they cannot be copied from the host into the image. This is because the image is mounted in read-only mode by default and the mount point is owned by the root user. To copy files into a mounted image, first become root and then mount the image with the --writable option to the mount sub-command.

Show Video Tutorial

A primary goal of Singularity is mobility. The single file image format makes mobility easy.

Because Singularity images are single files, they are easily copied and managed. You can copy the image to create a branch, share the image and distribute the image as easily as copying any other file you control!

If you want an automated solution for building and hosting your image, you can use our container registry Singularity Hub. Singulairty Hub can automatically build bootstrap specification files from a Github repository each time that you push. It provides a simple cloud solution for storing and sharing your image.

Read the original post:

Create an Image | Singularity

Related Posts