Containers

Overview

Apptainer is an HPC-focused container platform that runs containers as the calling user (no root required). It seamlessly converts and runs images from DockerHub and Sylabs Cloud.

Why use containers on HPC?

  • Reproducible environments across different systems
  • Pre-packaged software without complex installations
  • Data access through bind mounting

Apptainer is pre-installed on Camber. Check version:

apptainer --version

Pulling Images

Download container images from DockerHub or Sylabs Cloud:

# From DockerHub (most common)
apptainer pull docker://python:3.11
apptainer pull docker://ubuntu:22.04

# From Sylabs Cloud
apptainer pull library://lolcow:latest

Example output:

[user@login ~]$ apptainer pull docker://alpine:latest
INFO:    Converting OCI blobs to SIF format
WARNING: 'nodev' mount option set on /tmp, it could be a source of failure during build process
INFO:    Starting build...
INFO:    Fetching OCI image...
3.6MiB / 3.6MiB [=======================================] 100% 0s
INFO:    Extracting OCI image...
INFO:    Creating SIF file...
[=======================================] 100% 0s

Images are converted to SIF (Singularity Image Format) files locally.

Running Containers

Execute specific commands:

apptainer exec python_3.11.sif python --version
apptainer exec ubuntu_22.04.sif apt list --installed

Interactive shell:

apptainer shell python_3.11.sif  # Enter container interactively

Run default command:

apptainer run python_3.11.sif    # Runs container's default command
./lolcow_latest.sif               # Direct execution (some containers)

Example output from direct execution:

 ______________________________
< Tue Aug 12 03:45:38 UTC 2025 >
 ------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Data Access

Default access: Your $HOME directory is automatically available inside containers:

apptainer exec alpine_latest.sif ls -ld $HOME
# Output: drwx------ 6 username username 6144 Aug 12 03:45 /camber/home/username

Mount additional directories:

# Mount host directory inside container
apptainer exec -B $HOME/data:/data python_3.11.sif python /data/script.py

# Mount multiple directories
apptainer exec -B $HOME/data:/data,$HOME/results:/results python_3.11.sif python /data/analysis.py

Example with outputs directory:

# First, check the host directory contents
ls -l $HOME/outputs/
# Output: -rw-r--r-- 1 username username 0 Aug 12 03:54 test.txt

# Bind mount it to /lustre inside the container
apptainer exec -B $HOME/outputs:/lustre alpine_latest.sif ls -l /lustre
# Output: -rw-r--r-- 1 username username 0 Aug 12 03:54 test.txt

Syntax:

apptainer exec -B /host/path:/container/path image.sif command

Container Information

Inspect container metadata, labels, environment variables, and other properties:

# Basic metadata
apptainer inspect python_latest.sif

Example output:

org.label-schema.build-arch: amd64
org.label-schema.build-date: Tuesday_12_August_2025_3:58:51_UTC
org.label-schema.schema-version: 1.0
org.label-schema.usage.apptainer.version: 1.4.2-1
org.label-schema.usage.singularity.deffile.bootstrap: docker
org.label-schema.usage.singularity.deffile.from: python:latest

Environment variables: View environment variables defined in the container:

apptainer inspect -e python_latest.sif

Example output:

# === /.singularity.d/env/10-docker2singularity.sh ===
#!/bin/sh
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export GPG_KEY="${GPG_KEY:-7169605F62C751356D054A26A821E680E5FA6305}"
export PYTHON_VERSION="${PYTHON_VERSION:-3.13.6}"
export PYTHON_SHA256="${PYTHON_SHA256:-17ba5508819d8736a14fbfc47d36e184946a877851b2e9c4b6c43acb44a3b104}"

# === /.singularity.d/env/90-environment.sh ===
#!/bin/sh
# Copyright notices and custom environment code follow...

Quick Reference

# Pull from DockerHub
apptainer pull docker://ubuntu:22.04

# Run with data access
apptainer exec -B $HOME/data:/data ubuntu_22.04.sif python3 /data/script.py

# Interactive session
apptainer shell ubuntu_22.04.sif

# Check container info
apptainer inspect ubuntu_22.04.sif