Create Apptainer 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. Apptainer 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. Apptainer 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 apptainer 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 Apptainer as well. You can use a docker container from here and run:

sudo apptainer 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 Apptainer 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 Apptainer image using:

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

Build from Apptainer Definition File

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

Click here for the official documentation on creating recipes

To build an image from a recipe file just use:

sudo apptainer 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 Apptainer images without ever installing it on your own machine. You can create Apptainer images on the hub. Click here for more information.