Installing Apptainer
Since this guide assumes you are building Apptainer from source, it walks you through the installation process. For alternative installation methods, including pre-compiled binaries, refer to the [installation section of the admin guide](apptainer.org/docs/admin/main/installation.html).
Install System Dependencies
On Debian-based systems (e.g., Ubuntu):
sudo apt-get update
sudo apt-get install -y \
build-essential \
libseccomp-dev \
pkg-config \
uidmap \
squashfs-tools \
fakeroot \
cryptsetup \
tzdata \
dh-apparmor \
curl wget git
On RHEL or its derivatives:
sudo dnf groupinstall -y 'Development Tools'
sudo dnf install -y epel-release
sudo dnf install -y \
libseccomp-devel \
squashfs-tools \
fakeroot \
cryptsetup \
wget git
On SLE/openSUSE:
sudo zypper install -y \
libseccomp-devel \
libuuid-devel \
openssl-devel \
cryptsetup sysuser-tools \
gcc go
Install Go
Apptainer is written in Go, so you may need to install a newer version of Go. It’s recommended to install Go from the [official binaries](golang.org/dl/).
Download and install the latest Go version:
export GOVERSION=1.20.10 OS=linux ARCH=amd64
wget -O /tmp/go${GOVERSION}.${OS}-${ARCH}.tar.gz \
https://dl.google.com/go/go${GOVERSION}.${OS}-${ARCH}.tar.gz
sudo tar -C /usr/local -xzf /tmp/go${GOVERSION}.${OS}-${ARCH}.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
source ~/.bashrc
Install golangci-lint
If you plan to contribute to Apptainer, install golangci-lint
for code consistency checks:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.1
echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.bashrc
source ~/.bashrc
Clone the Apptainer Repo
Clone the repository and build the specific version of Apptainer:
git clone https://github.com/apptainer/apptainer.git
cd apptainer
git checkout v1.3.4
Compile Apptainer
You can configure, build, and install Apptainer using the following commands:
./mconfig
cd $(/bin/pwd)/builddir
make
sudo make install
Verify the installation:
apptainer --version
Compiling Dependent FUSE-based Packages
Some FUSE-based packages may need to be installed for Apptainer. For Debian:
sudo apt-get install -y autoconf automake libtool pkg-config libfuse3-dev zlib1g-dev
For RHEL:
sudo dnf install -y autoconf automake libtool pkgconfig fuse3-devel zlib-devel
Download, compile, and install the dependencies:
./scripts/download-dependencies
./scripts/compile-dependencies
sudo ./scripts/install-dependencies
AppArmor Profile (Ubuntu 23.10+)
To allow Apptainer to create unprivileged user namespaces on Ubuntu 23.10+:
sudo tee /etc/apparmor.d/apptainer << 'EOF'
# Permit unprivileged user namespace creation for apptainer starter
abi <abi/4.0>,
include <tunables/global>
profile apptainer /usr/local/libexec/apptainer/bin/starter{,-suid}
flags=(unconfined) {
userns,
include if exists <local/apptainer>
}
EOF
sudo systemctl reload apparmor
Alternatively, you can allow all unprivileged users to create namespaces:
sudo sh -c 'echo kernel.apparmor_restrict_unprivileged_userns=0 >/etc/sysctl.d/90-disable-userns-restrictions.conf'
sudo sysctl -p /etc/sysctl.d/90-disable-userns-restrictions.conf
Building and Installing from RPM
For RHEL/Fedora, install additional packages and build Apptainer as an RPM:
sudo dnf install -y rpm-build golang
wget https://github.com/apptainer/apptainer/releases/download/v1.3.4/apptainer-1.3.4.tar.gz
rpmbuild -tb apptainer-1.3.4.tar.gz
sudo rpm -Uvh ~/rpmbuild/RPMS/x86_64/apptainer-1.3.4-1.el8.x86_64.rpm