Cheatography
https://cheatography.com
A quick reference guide for using Apptainer
Pulling images
apptainer pull <output.sif> shub://[reposiory/name/] |
Pull sif image from Singularity Hub |
apptainer pull <output.sif> docker://[docker_image] |
Pull Docker image from Dockerhub or remote container registry |
apptainer pull <output.sif> docker-daemon://[image_name] |
Pull docker image from local Docker image builds |
Before a Docker image can be used by Apptainer, it must be pulled to make it compatible with Apptainer.
Apptainer Cache
apptainer cache list |
Show basic details on what is in the local cache |
apptainer cache list -v |
Lists SIF images stored in the local cache |
apptainer cache clean |
Remove everything stored in the local cache |
By default, Apptainer stores the cache in $HOME/.apptainer/cache
, but can be changed by modifying the APPTAINER_CACHEDIR
variable
Executing commands from a image
apptainer exec [SIF_File.sif] <command_to_execute> |
Execute a command from the image |
apptainer run [SIF_File.sif] |
Executes the default command for the image |
apptainer inspect -r [SIF_File.sif] |
Inspect the SIF image and locate the default command |
apptainer shell [SIF_File.sif] |
Open an interactive shell within the container |
Binding host directories to a container
apptainer shell -B /directory/to/add [SIF_File.sif] |
Add a directory to the same location in the container |
apptainer shell -B /directory/to/add:/new/location/in_container [SIF_File.sif] |
Add a directory to a different location in the container |
The "-B" arguement can apply to the shell
, exec
, and run
sub commands of Apptainer. shell
is only used as an example. This is refered to as " Binding" the directory inside of the container.
Building Apptainer Images
apptainer build /path/to/ouput.sif /path/to/input.def |
Build a sif image using the .def definition file. |
Apptainer Definition File Keywords
Apptainer |
Docker Equivalent |
Description |
From: |
FROM |
Base image for the image |
%files |
ADD |
Add files from the host system into the image |
%environment |
ENV |
Add environment variables to the image |
%post |
RUN |
Run commands to build or install software in the image |
%runscript |
CMD / ENTRYPOINT |
What to run when the container is used with apptainer run
|
%setup |
|
Run commands on the host system before starting the build |
%labels |
LABEL |
Add metadata labels |
Bootstrap |
|
Tells Apptainer which type of source the base image will be. |
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets