4.4 Run and execution process

Once we have some image files (or directories) ready, we can run or favourite processes.

4.4.1 Singularity shell

The straight-forward exploratory approach, equivalent to docker run -ti myimage /bin/shell. But with a more handy syntax.

    singularity shell fastqc-multi-bowtie.sif
Move around the directories and notice the different isolation approach compared to Docker. You can access most of the host filesystem.

4.4.2 Singularity exec

That is the most common way to execute Singularity (equivalent to docker exec). That would be the normal approach in HPC environments.

    singularity exec fastqc-multi-bowtie.sif fastqc

4.4.3 Singularity run

This executes runscript from recipe definition (equivalent to docker run). Not so common for HPC uses. More for instances (servers).

    singularity run fastqc-multi-bowtie.sif

4.4.4 Environment control

By default Singularity inherits our profile environment (e.g., PATH environment variable). This may be convenient for some circumstances, but it can also lead to unexpected problems if you are not aware, when your own environment clashes with the default one from the image.

    singularity shell -e fastqc-multi-bowtie.sif

    singularity exec -e fastqc-multi-bowtie.sif fastqc

    singularity run -e fastqc-multi-bowtie.sif

Compare env command with and without -e modifier.

    singularity exec fastqc-multi-bowtie.sif env
    singularity exec -e fastqc-multi-bowtie.sif env

4.4.5 Execute from sandboxed images / directories

    singularity exec ./sandbox ls -l /etc/myetc.conf
    # We can see file created in the directory before
    singularity exec ./sandbox bash -c 'apt-get update && apt-get install python'
    # We cannot install python
    singularity exec --writable ./sandbox bash -c 'apt-get update && apt-get install python'
    # We needed to add writable parameter

4.4.6 Execute straight from a registry

Image is actually downloaded (and if a Docker one, converted) and stored in Singularity cache directory.

    singularity exec docker://ncbi/blast:2.10.1 blastp -version