Skip to content

kaczmarj/apptainer-in-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apptainer in Docker

Docker images available at kaczmarj/apptainer Docker pulls Docker pulls

The Dockerfile in this repository builds Apptainer. The resulting Docker image can be used on any system with Docker to build Apptainer images. This project is targeted towards high-performance computing users who have Apptainer/Singularity installed on their clusters but do not have Apptainer/Singularity on their local computers to build images.

Note: This project previously built Singularity. See the Linux Foundation post regarding the name change to Apptainer.

Convert local Docker image to Apptainer format

In the following example, we convert an existing Docker image to Apptainer format.

$ docker pull alpine:3.18.2
$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/work \
    kaczmarj/apptainer build alpine_3.18.2.sif docker-daemon://alpine:3.18.2

This output .sif file will be owned by root, so you can change ownership:

sudo chown USER:GROUP alpine_3.18.2.sif

Build Apptainer image in Docker

With the following command, we build a small Apptainer image defined in test_alpine.def. This Apptainer image will be saved in the current directory myimage.sif.

$ docker run --rm --privileged -v $(pwd):/work kaczmarj/apptainer \
  build myimage.sif test_alpine.def

Run Apptainer image in Docker

One can run a Apptainer image within this Docker image. This is not recommended, but it is possible.

$ docker run --rm --privileged kaczmarj/apptainer \
  run shub://GodloveD/lolcow

Here is the output:

INFO:    Downloading shub image
87.6MiB / 87.6MiB [======================================================================================================================================================] 100 % 1.4 MiB/s 0s
 _________________________________________
/ He that is giddy thinks the world turns \
| round.                                  |
|                                         |
| -- William Shakespeare, "The Taming of  |
\ the Shrew"                              /
 -----------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Build image

Apptainer version 1.2.0:

$ docker build --build-arg APPTAINER_COMMITISH=v1.2.0 -t apptainer:1.2.0 .

Bleeding-edge (main branch):

$ docker build --build-arg APPTAINER_COMMITISH=main -t apptainer:latest .