How to get containers¶
In this tutorial you will learn
- How to pull existing containers from a repository
- How to convert Docker images to Apptainer images
- Where to keep the Apptainer cache and temporary files
Building containers from scratch requires root privileges, so it cannot be
done on Roihu as is.
- Instead, you will have to import a ready image file (or use Tykky if containerizing a Conda/pip environment). There are various options to do this.
- Alternatively, the
fakerootfeature can be used to build containers without root privileges. See a separate tutorial on this topic.
1. Run or pull an existing Singularity container from a repository¶
-
It is possible to run containers directly from a repository:
- This can, however, lead to a batch job failing if there are network problems.
-
Usually it is better to pull the container first and then use the image file:
Roihu base containers are available through Satama.
2. Convert an existing Docker container to an Apptainer container¶
Docker images are downloaded as layers. These layers are stored in a cache
directory.
- The default location of the cache is
$HOME/.apptainer/cache. - Since the home directory has limited capacity and some images can be large,
it's best to set
$APPTAINER_CACHEDIRto point to some other location with more space.
Option A¶
-
If you're running on a node with no fast local storage, you can use e.g.
/scratch:
Option B¶
-
If you're running interactively or as a batch job on an I/O node, you can use the fast temporary local storage:
The hugemem (XL) and visualization (Viz) nodes additionally provide reservable local scratch under
$LOCAL_SCRATCH(e.g.--gres=nvme:<amount-in-GB>on XL nodes). This is billed separately and, for Viz nodes, the amount is not yet finalized. More information is available in Docs CSC.
Build the image¶
-
Avoid some unnecessary warnings by unsetting a certain environment variable:
-
You can now run
apptainer build:
You can find more detailed instructions on converting Docker containers in
Docs CSC.
3. Build the container on another system and transfer the image file to Roihu¶
To do this you will need access to a system where you have root privileges
and that has Apptainer installed.
-
You can check the current Apptainer version on Roihu with:
-
After creating an image file, you can transfer it to Roihu.
More information¶
This tutorial is meant as a brief introduction to get you started.
When searching online for instructions, make sure that the instructions
are for the same version of Apptainer as you are using. There have been some
command syntax changes etc. between versions, so older instructions may not
work as is. Also note that Apptainer was formerly known as Singularity.
For more detailed instructions, see the official
Apptainer documentation.