6. How to build a container with apptainer build --force --fakerootΒΆ
Although BMRC does not have a dedicated sandbox to build containers at the moment, fakeroot is enabled in both the login nodes and compute nodes allowing researchers to build containers as needed
Build a container on a BMRC login node
- To illustrate this functionality, create an example container definition file my_container.def from a shell session on NeSI as follows:
cat << EOF > my_container.def
BootStrap: docker
From: ubuntu:20.04
%post
apt-get -y update
apt-get install -y wget
EOF
- Build command follows the format of
apptainer build --force --fakeroot NAME_OF_THE_CONTAINER_AFTER_THE_BUILD.aif name_of_the.def - If you have
$APPTAINER_BINDset globally, unset it withunset APPTAINER_BINDforapptainer buildcommands. Otherwise thebuildcommands will fail as bind mounts set via this environment variable are NOT supported during build operations- The build process executes in a special, isolated environment and does NOT honor the
APPTAINER_BINDorAPPTAINER_BINDPATHenvironment variables. - Only directories specified with the
--bindargument are recognized and mounted during the build's%postor%testsections, if the destination mount points already exist in the bootstrap image
- The build process executes in a special, isolated environment and does NOT honor the
Build a container on BMRC via Slurm job
- Since some container builds can consume a significant amount of CPUs and memory, our recommendation is to perform these builds via a Slurm job (either interactive or batch queue). Unfortunately, BMRC compute nodes do not have www access by default. Please contact the KIR Research Computing Manager for assistance configuring your environment to allow compute nodes www access.