All materials (c) 2020-2023 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/
build --remote
option has been removed from Apptainer because there is no standard protocol or non-commercial service that supports itconda install
commandslibrary:
bootstrap agent does not work in Apptainer by default
bootstrap agent
and source
used to build the base OS
Example using “docker” bootstrap agent and an image from DockerHub:
Bootstrap: docker
From: ubuntu:20.04
Example using “yum” bootsrtap 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, %help
%apps*
sections for SCIF Apps supportin 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/myfile
Can be used to set any environment variables, e.g $PATH
%environment
export PATH=/app/bin:$PATH
in the container
after base container is running%post
apt install python3
pip install numpy
Defines the runscript
Executed when container run with:
apptainer run myprog.sif
or
./myprog.sif
Similar to the %runscript
section
Executed when run with:
apptainer start instance example.sif
Mainly 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:
apptainer test example.sif
Can be used to add metadata, e.g. contact information
%labels
Maintainer my.address@example.net
Can be seen with:
apptainer inspect --labels example.sif
Add usage instructions etc
%help
Usage:
apptainer exec myprog.sif myprog --help
Can be seen with:
apptainer run-help example.sif
Bootstrap: 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 apptainer build --sandbox alpine/ docker://alpine
Creates 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 apptainer shell --writable alpine
Depending 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 apptainer build alpine.sif alpine
Transfer image file to Puhti for use
history
can help, but if you try many things, keep track of what worked./home
, /tmp
, or any other directories that might get commonly binded on).%help
or %apphelp
section. A good container tells the user how to interact with it.%environment
and %appenv
sections of the build recipe./etc/passwd
, /etc/group
, and /etc/shadow
do not contain secrets.