Skip to content

Commit 54c3f84

Browse files
authored
Merge pull request #335 from NYU-RTS/Amanda-dong-patch-1
Replace Singularity with Apptainer in documentation
2 parents d9b9937 + f0910b7 commit 54c3f84

6 files changed

Lines changed: 57 additions & 45 deletions

File tree

_typos.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[default.extend-words]
22
# Scientific Software
33
namd = "namd"
4+
# Apptainer
5+
Apptainer = "Apptainer"
46

57
[default.extend-identifiers]
68
# Technical terms

docs/hpc/07_containers/01_intro.md

Lines changed: 55 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,103 @@
11
# Custom Applications with Containers
22

3-
## What is Singularity?
4-
Singularity is a container based Linux kernel workspace that works just like Docker. You can run pre-built programs in containers without having to worry about the pre-install environment. You can even run Docker containers with Singularity. Please see the [Singularity and Docker](https://docs.sylabs.io/guides/4.3/user-guide/singularity_and_docker.html) documentation by Syslabs for details about all the ways Singularity supports Docker. For a detailed introduction on Singularity, visit their [official site](https://apptainer.org/documentation/).
3+
## What is Apptainer?
4+
Apptainer is a container based Linux kernel workspace that works just like Docker. You can run pre-built programs in containers without having to worry about the pre-install environment. You can even run Docker containers with Apptainer. Please see the [Apptainer and Docker](https://apptainer.org/docs/user/main/docker_and_oci.html) documentation by Syslabs for details about all the ways Apptainer supports Docker. For a detailed introduction on Apptainer, visit their [official site](https://apptainer.org/documentation/).
55

6-
The Singularity we use is actually an alias for the name Apptainer. When we transition to the new Torch cluster you will only see reference to Apptainer. The reason for this is that there were two container projects with the name Singularity. The original free and open-source (FOSS) project and a closed-source corporate fork. The FOSS version has renamed itself to Apptainer to avoid confusion and this is the version we use.
6+
Apptainer is the continuation of the Singularity project. When we transition to the new Torch cluster you will only see reference to Apptainer. The reason for this is that there were two container projects with the name Singularity. The original free and open-source (FOSS) project and a closed-source corporate fork. The FOSS version has renamed itself to Apptainer to avoid confusion and this is the version we use.
77

8-
## Why do we use Singularity
9-
There are multiple reasons to use Singularity on the HPC clusters:
10-
- **Security**: Singularity provides a layer of security as it does not require any root access on our clusters. This makes it safer against malware and bad scripts that might jeopardize the outer system. Thus we only support Singularity on our clusters (there are not other options such as Kubernetes or Docker on our clusters right now).
11-
- **Containerization**: Singularity will run all your images (packaged and pre-built programs) inside of its containers, each container works like a small vm. They contain all the required environment and files of a single Linux kernel and you don't have to worry about any pre-installation nonsense.
8+
## Why Do We Use Apptainer
9+
There are multiple reasons to use Apptainer on the HPC clusters:
10+
- **Security**: Apptainer provides a layer of security as it does not require any root access on our clusters. This makes it safer against malware and bad scripts that might jeopardize the outer system. Thus we only support Apptainer on our clusters (there are not other options such as Kubernetes or Docker on our clusters right now).
11+
- **Containerization**: Apptainer will run all your images (packaged and prebuilt programs) inside of its containers, each container works like a small vm. They contain all the required environment and files of a single Linux kernel and you don't have to worry about any pre-installation issues.
1212
- **Inter-connectivity**: Containers are able to talk to each other, as well as the home system, so while each container has its own small space, they are still a part of a big interconnected structure. Thus enabling you to connect your programs.
13-
- **Accessibility**: Probably the most important feature of all, Singularity allows you to run your program in 2 to 3 simple steps, as shown below.
13+
- **Accessibility**: Probably the most important feature of all, Apptainer allows you to run your program in 2 to 3 simple steps, as shown below.
1414

15-
## How to run a singularity container
16-
There are 3 steps to run a Singularity container on our clusters:
15+
## How to Run an Apptainer Container
16+
There are 3 steps to run an Apptainer container on our clusters:
1717

18-
### 1. pull a image from Singularity hub or Docker hub
18+
:::warning
19+
Running containers on login nodes is not encouraged, as processes may be terminated due to resource limits; please use compute nodes instead.
20+
:::
21+
22+
### 1. Pull an Image from Docker Hub
1923
```sh
20-
$ singularity pull <image name>
21-
# image name can be for example shub://vsoch/hello-world or docker://godlovedc/lolcow
22-
```
24+
$ apptainer pull docker://godlovedc/lolcow
25+
# image name can be for example docker://godlovedc/lolcow
26+
```
2327

24-
![singularity1](./static/singularity1.png)
28+
![apptainer1](./static/apptainer1.png)
2529

26-
### 2. build the image
30+
### 2. Build the Image (Optional)
2731
```sh
28-
$ singularity build <a name of your choosing>.simg:rw <image name>
32+
$ apptainer build <a name of your choosing>.sif <image name>
2933
# the image name can be a local image or an image from a hub
3034
```
31-
We add the `:rw` tag at the end of the `.simg` file to explicitly give it "read and write" permissions while building.
3235

33-
![singularity2](./static/singularity2.png)
36+
Building an image is optional for most use cases. In many cases, users can directly run containers pulled from Docker Hub without building a local image.
37+
38+
![apptainer2](./static/apptainer2.png)
3439

3540
You can now run your container using the built image.
3641

37-
### 3. run container
42+
### 3. Run Container
3843
```sh
3944
# this is one way of running a container
40-
$ singularity run <image name>.simg:ro
45+
$ apptainer run <image name>.sif
4146
# this is another way to run a container
42-
$ ./<image name>.simg:ro
47+
$ ./<image name>.sif
4348
```
4449

45-
Unlike in the build phase, we add the `:ro` tag which means "read only" - as we are now just executing the image, not building it, and thus do not need it to be written.
46-
:::warning
47-
Write access causes the Singularity image to be locked and it can become inaccessible while it is in read/write mode, so read only mode is best for executing commands.
50+
:::info
51+
Apptainer images are immutable by default. You can mount an writable overlay file and edit files within the overlay.
4852
:::
4953

5054
running this would yield a menu for output:
5155

52-
![singularity3](./static/singularity3.png)
56+
![apptainer3](./static/apptainer3.png)
5357

5458
#### Enter Container
5559
```sh
56-
singularity shell <image name>.simg:ro
60+
apptainer shell <image name>.sif
5761
# after this step, you will be going into the container and start your programming
5862
```
5963

60-
![singularity4](./static/singularity4.png)
64+
![apptainer4](./static/apptainer4.png)
6165

6266
:::tip
63-
#### Run commands outside the container
67+
68+
Run commands outside the container
69+
6470
You can run commands for the container using exec arguments without actually going into the container
71+
6572
```sh
66-
$ singularity exec <image name>.simg:ro <commands>
73+
$ apptainer exec <image name>.sif <commands>
6774
# adding commands to the back will return the display result of these commands in the container without actually going into the container
6875
```
76+
:::
6977

70-
Example:
78+
### Using `fakeroot`
7179

72-
![singularity5](./static/singularity5.png)
73-
:::
80+
In some cases, you may need elevated permissions inside the container to install software or modify system files. Apptainer provides a `--fakeroot` option that allows you to run commands inside the container with root-like privileges, without requiring actual root access on the system.
7481

75-
That's it! Now you're good to go and can just use these simple steps to run singularity images and run your programs.
82+
```sh
83+
$ apptainer exec --fakeroot <image name>.sif <commands>
84+
```
7685

77-
For full information and documentation please visit [Singularity](https://sylabs.io/docs/).
86+
That's it! Now you're good to go and can just use these simple steps to run Apptainer images and run your programs.
7887

79-
## How to Create a Singularity Container
80-
So what if you want to create an image from your container and save it for a rainy day?
88+
For full information and documentation please visit [Apptainer](https://apptainer.org/).
8189

82-
Apptainer documentation has [instructions for building containers](https://apptainer.org/docs/user/latest/build_a_container.html) for your convenience. Please read through them to create your own Singularity container and package it into an image!
90+
## How to Create an Apptainer Container
91+
So what if you want to create an image from your container and save it for a rainy day?
8392

84-
Similarly, you can build docker containers using the information from [Docker's documentation](https://docs.docker.com/get-started/docker-concepts/building-images/). You can then upload them onto docker hub and pull them using Singularity. Singularity supports all docker images!
93+
Apptainer documentation has [instructions for building containers](https://apptainer.org/docs/user/latest/build_a_container.html) for your convenience. Please read through them to create your own Apptainer container and package it into an image!
8594

86-
## Singularity vs Docker
87-
Why are there so many mentions of Docker? The reason is that Singularity is essentially the same as Docker and you don't need to relearn Singularity if you already have experience with Docker. Now let's get into some pros and cons between the two programs.
88-
- Docker is more accepted commercially than Singularity. You can download and run Docker on your own computer with any operating system and build containers with ease while Singularity is used in a more academic setting. Singularity only supports Linux operating systems and cannot run on a Windows Linux Kernel (your Windows Ubuntu), so it is much more limited.
89-
- However, Docker requires root or admin access for the operating system it deploys on, and our clusters do not offer that access to any software that requires this criteria. Thus Docker is not available on the clusters and Singularity is.
90-
- A silver lining in all of this is that Singularity fully supports Docker images and you can do everything in Docker and push your image to Docker Hub and pull them on the clusters. Thus making sure that you don't need to relearn Singularity all over again and can just use it through the simplest of commands in this wiki.
95+
Similarly, you can build docker containers using the information from [Docker's documentation](https://docs.docker.com/get-started/docker-concepts/building-images/). You can then upload them onto docker hub and pull them using Apptainer. Apptainer supports all Docker images!
9196

92-
Good luck with Singularity, and have fun!
97+
## Apptainer vs Docker
98+
Why are there so many mentions of Docker? The reason is that Apptainer is essentially compatible with Docker and you don't need to relearn Apptainer if you already have experience with Docker. Now let's get into some pros and cons between the two programs.
99+
- Docker is more accepted commercially than Apptainer. You can download and run Docker on your own computer with any operating system and build containers with ease while Apptainer is used in a more academic setting. Apptainer primarily supports Linux environments and is designed for HPC use cases.
100+
- However, Docker requires root or admin access for the operating system it deploys on, and our clusters do not offer that access to any software that requires this criteria. Thus Docker is not available on the clusters and Apptainer is.
101+
- A silver lining in all of this is that Apptainer fully supports Docker images and you can do everything in Docker and push your image to Docker Hub and pull them on the clusters. Thus making sure that you don't need to relearn workflows and can just use it through the simplest of commands in this documentation.
93102

103+
Good luck with Apptainer, and have fun!
124 KB
Loading
117 KB
Loading
75.5 KB
Loading
61.7 KB
Loading

0 commit comments

Comments
 (0)