A quick step-by-step guide to creating a Singularity container:

  1. Log in to the cluster
  2. On frontend01 or frontend02 type in 'id'
  3. Copy your user id (number of digits)
  4. Log out again
  5. Start singularity with a fresh container and a (root) shell inside it:
    singularity build --sandbox debian docker://debian
    sudo singularity shell --writeable debian

    Note: „sudo singulartiy“ is needed because you always keep the user you start the image as. So if you run singularity as root, you are root. In other words, if you're not root at startup, you won't be root at runtime! Also note that creating a singularity sandbox creates a directory, not an image file.

  6. Install the required packages and create a runscript inside the container, if you wish
  7. Make sure that the user with your copied id has read/execute permissions on the packages/runscript. If necessary, create a user with this id number.
  8. Create the image file of your sandbox:
    sudo singularity build debian.sif debian

    debian.sif will be a single file, ready to go.

    1. Copy the sif to the cluster and run your script (if present):
      srun singularity exec <container> <command>

      Where <container> is your image file and <command> is the path to your run script.

    2. Otherwise, just run the container so that you can run scripts in your home directory (example using the previously created Ubuntu container):
      [___@frontend01 ~]$ srun --pty singularity run ~/debian.sif
      [___@node131 ~]$ cat /etc/os-release | grep PRETTY_NAME 
      PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"

Of course, you can use sbatch scripts instead of calling srun directly, and you can also pull a fresh container, which works on the cluster frontends:

singularity pull docker://ubuntu

When you open a shell on your singularity image, your outer home directory is always mounted inside the container as your inner home directory. So you can put a script in your home directory on the cluster and use it inside the container in your home directory.

So again, 2 things to remember when starting a Singularity container:

  1. You stay who you are.
  2. Your home directory remains the same.

Some final notes: Running singularity on the frontends will cause a high load on the frontends and therefore we (the administrators) may kill this process if it disturbs other users. This is just a note and a reminder to always use srun or sbatch to start your project! ^^

Finally, we have Singularity versions 3.7.0, 3.1.0 and 2.7.5 installed on every machine. Please always use one of these versions (for compatibility reasons) until there is an update on the cluster.

  • Zuletzt geändert: 2024/04/19 13:45
  • von