https://github.com/kaczmarj/apptainer-in-docker
Apptainer in Docker!
https://github.com/kaczmarj/apptainer-in-docker
apptainer containers docker hpc singularity singularity-container
Last synced: about 2 months ago
JSON representation
Apptainer in Docker!
- Host: GitHub
- URL: https://github.com/kaczmarj/apptainer-in-docker
- Owner: kaczmarj
- License: apache-2.0
- Created: 2019-01-10T20:06:31.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-11-29T14:25:23.000Z (6 months ago)
- Last Synced: 2025-04-13T12:09:50.817Z (about 2 months ago)
- Topics: apptainer, containers, docker, hpc, singularity, singularity-container
- Language: Dockerfile
- Homepage:
- Size: 24.4 KB
- Stars: 46
- Watchers: 4
- Forks: 10
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Apptainer in Docker
[](https://hub.docker.com/r/kaczmarj/apptainer)
[](https://hub.docker.com/r/kaczmarj/apptainer)
[](https://hub.docker.com/r/kaczmarj/singularity)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](https://www.linuxfoundation.org/press/press-release/new-linux-foundation-project-accelerates-collaboration-on-container-systems-between-enterprise-and-high-performance-computing-environments) 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.
```bash
$ 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:
```bash
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`](test_alpine.def). This Apptainer image will be saved in the current directory `myimage.sif`.
```bash
$ 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.
```bash
$ 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:
```bash
$ docker build --build-arg APPTAINER_COMMITISH=v1.2.0 -t apptainer:1.2.0 .
```Bleeding-edge (main branch):
```bash
$ docker build --build-arg APPTAINER_COMMITISH=main -t apptainer:latest .
```