Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions software/Apptainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
Copyright 2026, Center for High Throughput Computing, University of Wisconsin - Madison

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# Apptainer

Container definition files for installing Apptainer.
**This is intended for "nested" containers.**

> [!IMPORTANT]
> You do not need to do this for the "normal" use of Apptainer containers on CHTC.
> This is explicitly for the case where you need to be able to launch an Apptainer container ***from inside another container***!

## About nested containers

Normal execution of a container on CHTC has the correct permissions set automatically for everything to work as expected.
But those permissions do not extend into launching a container from inside of an already running container.
The result is usually some form of "permission denied" error.

90 changes: 90 additions & 0 deletions software/Apptainer/apptainer-in-apptainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<!--
Copyright 2026, Center for High Throughput Computing, University of Wisconsin - Madison

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# Apptainer-in-Apptainer

This recipe provides the definition file for the "parent" Apptainer container,
which has the ability to launch a "child" Apptainer container inside of it.

# Launching inner container

To run the inner container, you need to use the `--unsquash` argument with your `apptainer` command.
For example,

```
apptainer exec --unsquash my_inner_container.sif inner_script.sh
```

## Bare minimum setup

These images have the bare minimum required in order to use Apptainer inside of Apptainer.

* [minimal-ubuntu.def](minimal-ubuntu.def)
* [minimal-rocky.def](minimal-rocky.def)

## With "nice to have" packages

These images have what is required to use Apptainer inside of Apptainer,
as well as some additional "common" programs that are useful to have.
For a full list of additional packages, see the definition file.

* [nice-ubuntu.def](nice-ubuntu.def)
* [nice-rocky.def](nice-rocky.def)

## [minimal-ubuntu.def](minimal-ubuntu.def)

| | | |
| ---: | :--- | :--- |
| *Type* | **Apptainer** | |
| *OS* | Ubuntu 24.04 (Debian) | |
| *Base image* | **ubuntu:24.04** | *DockerHub* |
| *Updated* | 2026-04-27 | *Andrew Owen* |
| *Last tested on HTC* | 2026-04-27 | *Andrew Owen* |
| *Last tested on HPC* | - | - |

## [minimal-rocky.def](minimal-rocky.def)

| | | |
| ---: | :--- | :--- |
| *Type* | **Apptainer** | |
| *OS* | Rocky 9 (RHEL) | |
| *Base image* | **rockylinux:9** | *DockerHub* |
| *Updated* | 2026-04-27 | *Andrew Owen* |
| *Last tested on HTC* | 2026-04-27 | *Andrew Owen* |
| *Last tested on HPC* | - | - |

## [nice-ubuntu.def](nice-ubuntu.def)

| | | |
| ---: | :--- | :--- |
| *Type* | **Apptainer** | |
| *OS* | Ubuntu 24.04 (Debian) | |
| *Base image* | **ubuntu:24.04** | *DockerHub* |
| *Updated* | 2026-04-27 | *Andrew Owen* |
| *Last tested on HTC* | 2026-04-27 | *Andrew Owen* |
| *Last tested on HPC* | - | - |

## [nice-rocky.def](nice-rocky.def)

| | | |
| ---: | :--- | :--- |
| *Type* | **Apptainer** | |
| *OS* | Rocky 9 (RHEL) | |
| *Base image* | **rockylinux:9** | *DockerHub* |
| *Updated* | 2026-04-27 | *Andrew Owen* |
| *Last tested on HTC* | 2026-04-27 | *Andrew Owen* |
| *Last tested on HPC* | - | - |

22 changes: 22 additions & 0 deletions software/Apptainer/apptainer-in-apptainer/minimal-rocky.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Bootstrap: docker
From: rockylinux:9

%post
# base dnf/yum setup
dnf -y update && \
dnf -y install yum-utils && \
dnf -y config-manager --set-enabled crb && \
dnf -y install epel-release

dnf -y install --allowerasing \
cpio \
git \
rpm

# Installing unprivileged apptainer inside of the container
# adapted from https://apptainer.org/docs/admin/1.4/installation.html#install-unprivileged-from-pre-built-binaries
mkdir -p /opt
curl -s https://raw.githubusercontent.com/apptainer/apptainer/main/tools/install-unprivileged.sh | bash -s - /opt/apptainer

%environment
export PATH="/opt/apptainer/bin:${PATH}"
20 changes: 20 additions & 0 deletions software/Apptainer/apptainer-in-apptainer/minimal-ubuntu.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Bootstrap: docker
From: ubuntu:24.04

%post
export DEBIAN_FRONTEND=noninteractive
apt update -y
apt install -y \
bash \
cpio \
curl \
git \
rpm2cpio

# Installing unprivileged apptainer inside of the container
# adapted from https://apptainer.org/docs/admin/1.4/installation.html#install-unprivileged-from-pre-built-binaries
mkdir -p /opt
curl -s https://raw.githubusercontent.com/apptainer/apptainer/main/tools/install-unprivileged.sh | bash -s - /opt/apptainer

%environment
export PATH=/opt/apptainer/bin:$PATH
33 changes: 33 additions & 0 deletions software/Apptainer/apptainer-in-apptainer/nice-rocky.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Bootstrap: docker
From: rockylinux:9

%post
# base dnf/yum setup
dnf -y update && \
dnf -y install yum-utils && \
dnf -y config-manager --set-enabled crb && \
dnf -y install epel-release

# well rounded basic system to support a wide range of user jobs
dnf -y groupinstall "Development Tools" "Scientific Support"

dnf -y install --allowerasing \
cpio \
git \
nano \
python3 \
python3-pip \
python3-devel \
rpm \
tree \
unzip \
vim \
wget

# Installing unprivileged apptainer inside of the container
# adapted from https://apptainer.org/docs/admin/1.4/installation.html#install-unprivileged-from-pre-built-binaries
mkdir -p /opt
curl -s https://raw.githubusercontent.com/apptainer/apptainer/main/tools/install-unprivileged.sh | bash -s - /opt/apptainer

%environment
export PATH="/opt/apptainer/bin:${PATH}"
28 changes: 28 additions & 0 deletions software/Apptainer/apptainer-in-apptainer/nice-ubuntu.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Bootstrap: docker
From: ubuntu:24.04

%post
export DEBIAN_FRONTEND=noninteractive
apt update -y
apt install -y \
bash \
cpio \
curl \
git \
nano \
python3 \
python3-pip \
rpm2cpio \
tar \
tree \
unzip \
vim \
wget

# Installing unprivileged apptainer inside of the container
# adapted from https://apptainer.org/docs/admin/1.4/installation.html#install-unprivileged-from-pre-built-binaries
mkdir -p /opt
curl -s https://raw.githubusercontent.com/apptainer/apptainer/main/tools/install-unprivileged.sh | bash -s - /opt/apptainer

%environment
export PATH=/opt/apptainer/bin:$PATH