Create Singularity Images


You can build a container using five possible inputs.

The possible type of targets for the build commands are:

  1. URI beginning with library://
  2. URI beginning with docker://
  3. URI beginning with shub://
  4. Existing container
  5. Singularity definition file or recipe

Note: The build procedure requires root access and therefore cannot be performed on Spiedie. You must build your image locally and then run it

You can take advantage of all the community built containers available on various container hubs as a starting point for your image. Singularity natively supports the Singularity Cloud, Docker Hub and Singularity Hub libararies on its command line for building, pulling and executing images.

Build from Sylab Library Image

To use a Singularity Cloud pre-built image, run the following:

sudo singularity build image_name.simg library://library/default/ubuntu

The above will generate a default ubuntu image downloaded from the Singularity Cloud library.

Note: Third-party containers may not work as expected on Spiedie

Build from Docker Hub Image

You can also take advantage of docker containers on Singularity as well. You can use a docker container from here and run:

sudo singularity build image_name.simg docker://ubuntu

This will build an image with the official docker image container of Ubuntu.

Note: Third-party containers may not work as expected on Spiedie

Build from Singularity Hub Image

You can use pre-built images on the Singularity Hub as a base for your local image.

sudo singularity build image_name.simg shub://[username]/[repo_name]

Note: Third-party containers may not work as expected on Spiedie

Build from an existing container

If you are more familiar with Docker and have a Docker image created locally, you can convert the image to a singularity image using:

sudo singularity build image_name.simg /path/to/target/image 

Build from Singularity Definition File

You can also create a singularity image by writing a definition file or singularity recipe.

Click here for the official documentation on creating recipes

To build an image from a recipe file just use:

sudo singularity build image_name.simg definition_file.def 

Click here for a collectoin of Spiedie-tested container recipes

This method of creating containers is highly suggested, as it ensures maximum reproducibility. You are also able to create singularity images without ever installing it on your own machine. You can create singularity images on the hub. Click here for more information