Software - Apptainer
Linux Cluster Institute - Intermediate
Alan Chapman�Systems Analyst - Software Specialist�RTO Research Computing�Arizona State University
Copyright © 2024 Arizona Board of Regents
Agenda
What are containers
Security concerns
Docker vs Apptainer vs …
When to use a container
Methods of Building / Obtaining Containers
2
Copyright © 2024 Arizona Board of Regents
3
What are Containers?
Containers are lightweight, stand-alone packages that contain everything needed to run a piece of software, including the code, runtime, libraries, and environment variables. Unlike virtual machines, containers do not bundle an entire operating system—just the necessary components, making them more efficient, portable, and scalable.
The efficiency of containers comes from their lightweight nature, allowing for rapid deployment and scaling. Their portability ensures that software runs consistently across different computing environments, from a developer's laptop to an HPC cluster. Scalability is achieved by easily adding more container instances to handle increased load.
Copyright © 2024 Arizona Board of Regents
4
HPC Security Concerns
Using containers introduces several security concerns, primarily around isolation and privilege escalation. Containers share the host's kernel, so a vulnerability in the container can potentially affect the entire system. Key concerns include:
Copyright © 2024 Arizona Board of Regents
5
Apptainer Security Management
Copyright © 2024 Arizona Board of Regents
6
Apptainer Security - Schedulers
Copyright © 2024 Arizona Board of Regents
7
Comparison of some container engines
Feature | Docker | Apptainer (Singularity) | Charliecloud |
Target Audience | General application development | HPC and scientific workloads | HPC users |
User Privileges | Requires root privileges | No root privileges required | No root privileges required |
Isolation | Strong OS-level isolation | Focus on user security | Simple isolation |
Ease of Use | Very user-friendly | Moderate learning curve | Simple but may require setup |
Portability | High portability | High portability | High portability |
Repositories | Docker Hub | User-built containers | User-built containers |
Integration | Broad ecosystem integration | HPC workload managers | HPC workload managers |
Performance | Moderate overhead | Low overhead | Minimal overhead |
Copyright © 2024 Arizona Board of Regents
8
Methods of building containers - Downloading
Downloading a container image from a container repository
$ apptainer pull docker://godlovedc/lolcow
INFO: Converting OCI blobs to SIF format
INFO: Starting build…
Getting image source signatures
Copying blob 3b61febd4aef done |
Copying blob 7fac07fb303e done |
Copying blob 9fb6c798fa41 done |
Copying blob 8e860504ff1e done |
Copying blob d010c8cf75d7 done |
Copying blob 9d99b9777eb0 done |
Copying config 38dc06177c done |
Writing manifest to image destination
INFO: Creating SIF file...
$ ls *.sif
lol_cowsay.sif
$
Copyright © 2024 Arizona Board of Regents
9
Methods of building containers - Building
$ vim rocky
bootstrap: yum
include: dnf
mirrorurl: http://dl.rockylinux.org/pub/rocky/{{ version }}/BaseOS/x86_64/os/
%environment
LC_ALL=C
%arguments
version=”8”
%post
dnf -y update
dnf install -y epel-release
dnf install -y wget git vim
$ apptainer build —build-args version=”8” rocky8.sif rocky
Copyright © 2024 Arizona Board of Regents
10
Methods of building containers - Building
$ vim rocky-docker
Bootstrap: docker
From: rockylinux:{{ version }}
%environment
LC_ALL=C
%arguments
version=”9.3”
%post
dnf -y update
dnf install -y epel-release
$ apptainer build --build-arg version="8.6" rocky8.6.sif rocky-docker
Copyright © 2024 Arizona Board of Regents
11
# First Stage
installed
Bootstrap: docker
From: golang:1.12.3-alpine3.9
Stage: one
%post
# prep environment
export PATH="/go/bin:/usr/local/go/bin:$PATH"
export HOME="/root"
cd /root
# insert source code, could also be copied from host with %files
cat << EOF > hello.go
package main
import "fmt"
func main() {
fmt.Printf("Hello World!\n")
}
EOF
# build go application
go build -o hello hello.go
# Second Stage
installed
Bootstrap: oras
From: ghcr.io/apptainer/alpine:3.15.0
Stage: two
%files from one
/root/hello /bin/hello
%runscript
hello
Multistage build
$ vim multistage
$ apptainer build gohello.sif multistage
Copyright © 2024 Arizona Board of Regents
12
$ vim spack.yaml
spack:
specs:
- gcc@12.3.0
- zlib-ng%gcc@12.3.0
- 7zip
- tcl
- lua
container:
format: singularity
images:
os: rockylinux:8
spack: 0.22.0
strip: true
os_packages:
final:
- libgfortran
- wget
labels:
apps: "gcc"
Multistage build with Spack
Copyright © 2024 Arizona Board of Regents
13
Resources
Copyright © 2024 Arizona Board of Regents
14
My Linkedin
Feedback
Copyright © 2024 Arizona Board of Regents
15
Questions / Discussion
Copyright © 2024 Arizona Board of Regents
Copyright © 2024 Arizona Board of Regents