5. Using Singularity

Singularity is a container technology. It allows the user to create a container (just like Docker ones) where all the needed software can be autonomously managed. By software we mean that almost everithing, from the operative system up, can be customized and run regardless the hosting OS.

5.1. Why singularity?

  • Singularity can run your choice of operative system;

  • Singularity can import your Docker images without superuser privileges and without Docker installed;

  • Singularity is a good way to share your code;

  • Configure on your personal PC; run in the CAPRI environment.

6. Singularity workflow

Important

This is not a Singularity tutorial. Please read the Singularity user guide first if you’re starting from scratch.

You tipically build the singularity file on your PC. The singularity image can then be transferred to CAPRI and run there.

6.1. Building the singularity image

Starting from a Singularity file you can work interactively on a singularity container:

sudo singularity build --sandbox tmpdir/ Singularity

or you can build a writable container

sudo singularity build --writable container.img Singularity

You can start from an already built image from the singularity hub

sudo singularity build container.img shub://vsoch/hello-world

or importing directly a Docker image

sudo singularity build container.img docker://ubuntu

6.2. Running the singularity image locally

You can run / modifiy your container locally on your PC until satisfied. To test run your image you can use

singularity run container.img

or, to access the container interactively

singularity exec container.img

6.3. Running the singularity image on CAPRI

Once copied on the CAPRI platform the singularity image can be executed with a slurm job file like the one described in Singularity job example