All material (C) 2020-2021 by CSC -IT Center for Science Ltd. This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 Unported License, http://creativecommons.org/licenses/by-sa/4.0/
conda install commands--remote option (no root access needed).Bootstrap agent and source used to build the base OS
Example using “library” bootstrap agent and an image from Sylabs Container Library:
Bootstrap: library
From: debian:7Example using “docker” bootstrap agent and an image from DockerHub:
Bootstrap: docker
From: ubuntu:20.04Example using “yum” bootsratp agent and distrubution files from CentOs site:
Bootstrap: yum
OSVersion: 7
MirrorURL: http://mirror.centos.org/centos-%{OSVERSION}/%{OSVERSION}/os/$basearch/
Include: yum%setup, %files, %environment, %post, %runscript, %startscript, %test, %labels, %helpin the host after the base container is runningCan be used to add files from the host system to the container
Syntax is: /path/in/host /path/in/container
%files
myfile /app/data/myfileCan be used to set any environment variables, e.g $PATH
Will be stored in file /environment inside the container
%environment
export PATH=/app/bin:$PATHin the container after base container is running%post
apt install python
pip install numpyDefines the runscript
Will be stored in file /singularity inside the container
Executed when container run with:
singularity run myprog.sif
or
./myprog.sifSimilar to the %runscript section
Executed when run with:
singularity start instance example.sifMainly used for containers that run services etc. Not that relevant on HPC environment
Runs at the very end of the build process to validate the container using a method of your choice
Can be run with:
singularity test example.sifCan be used to add metadata, e.g. contact information
%labels
Maintainer my.address@example.netCan be seen with:
singularity inspect --labels example.sifAdd usage instructions etc
%help
Usage:
singularity exec myprog.sif myprog --helpCan be seen with:
singularity run-help example.sifBootstrap: docker
From: ubuntu:20.04
%runscript
echo "This is what happens when you run the container..."
%files
hello_world /usr/bin/hello_world
hello2 /found/me/hello2
--sandbox)
You can start with a simple definition file (just the header) or from a bootstrap agent:
sudo singularity build --sandbox myprog library://centos:7.7Creates a folder structure instead of an image file
You can copy files directly to correct subfolder
To open in writable mode use option --writable
sudo singularity shell --writable myprogDepending on base image system, package managers can be used to install libraries and dependencies (apt install , yum install etc)
Installation as per software developer instructions
Build a production image from the sandbox
sudo singuluraity build myprog.sif myprog
Transfer image file to Puhti for use
history can help, but if you try many things, keep track of which one worked.