This is a simple tutorial on using Apptainer. It will walk users through creating a container, installing fortune, and running the container. Fortune is a program that outputs a random sentence or fact.
Step 1: Creating the definition file
The first step in creating a container is to make the definition file. The software used for this tutorial, fortune, has no dependencies so the def file will have few lines. It is recommended to create a new directory to hold all the files for a particular software. This tutorial uses a folder named fortune, where all the following commands are run from.
- mkdir fortune
Step 2: Building the container
Once the definition file is complete the container can be built. In this case a sandbox is not created first because no dependencies or changes are needed. It is better practice to create a sandbox first, add any further dependencies after testing, then create the apptainer container.
The container will be built with the below command in the current directory:
- apptainer build fortune.sif fortune.def
This pulls the Debian image, installs fortune, and creates a container with the name fortune.sif.
Step 3: Running the container
The final step is to run the container and start the environment.