Skip to content

Commit 7263412

Browse files
authored
Merge pull request #130 from NYU-RTS/usability_containers
Updated Containers tutorials
2 parents 93ccedf + 2c0f461 commit 7263412

File tree

3 files changed

+153
-147
lines changed

3 files changed

+153
-147
lines changed

docs/hpc/07_containers/01_intro.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
11
# Custom Applications with Containers
22

33
## 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.
5-
6-
For users who are familiar with Docker containers, Singularity works very similarly, and can even run Docker containers.
7-
8-
For a detailed introduction on Singularity, visit their official site [here](https://apptainer.org/documentation/)
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/).
95

106
## Why do we use Singularity
117
There are multiple reasons to use Singularity on the HPC clusters:
12-
1. 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)
13-
2. 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
14-
3. 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.
15-
4. Accessibility: Probably the most important feature of all, Singularity allows you to run your program in 2 to 3 simple steps, as shown in the topic how to run a singularity container.
8+
- **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).
9+
- **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.
10+
- **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.
11+
- **Accessibility**: Probably the most important feature of all, Singularity allows you to run your program in 2 to 3 simple steps, as shown below.
1612

1713
## How to run a singularity container
1814
There are 3 steps to run a Singularity container on our clusters:
1915

20-
pulling a image from Singularity hub or Docker hub
16+
### 1. pull a image from Singularity hub or Docker hub
2117
```sh
2218
$ singularity pull <image name>
2319
# image name can be for example shub://vsoch/hello-world or docker://godlovedc/lolcow
2420
```
2521

2622
![singularity1](./static/singularity1.png)
2723

28-
build the image
24+
### 2. build the image
2925
```sh
3026
$ singularity build <a name of your choosing>.simg:rw <image name>
3127
# the image name can be a local image or an image from a hub
@@ -34,31 +30,36 @@ We add the :rw tag at the end of the .simg to explicitly give it "read and write
3430

3531
![singularity2](./static/singularity2.png)
3632

37-
You can now run your container using the built image:
33+
You can now run your container using the built image.
3834

39-
run container
35+
### 3. run container
4036
```sh
4137
# this is one way of running a container
4238
$ singularity run <image name>.simg:ro
4339
# this is another way to run a container
4440
$ ./<image name>.simg:ro
4541
```
4642

47-
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. Writing 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.
43+
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.
44+
:::warning
45+
Writing 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.
46+
:::
4847

4948
running this would yield a menu for output:
5049

5150
![singularity3](./static/singularity3.png)
5251

53-
go into container
52+
#### Enter Container
5453
```sh
5554
singularity shell <image name>.simg:ro
5655
# after this step, you will be going into the container and start your programming
5756
```
5857

5958
![singularity4](./static/singularity4.png)
59+
:::
6060

61-
you can run commands for the container using exec arguments without actually going into the container
61+
#### Run commands outside the container
62+
You can run commands for the container using exec arguments without actually going into the container
6263
```sh
6364
$ singularity exec <image name>.simg:ro <commands>
6465
# adding commands to the back will return the display result of these commands in the container without actually going into the container
@@ -68,22 +69,22 @@ Example:
6869

6970
![singularity5](./static/singularity5.png)
7071

71-
That's it! Now you're good to go and can just use these simple steps to run singularity images and run your programs
72+
That's it! Now you're good to go and can just use these simple steps to run singularity images and run your programs.
7273

73-
For full information and documentation on Singularity, visit their site [here](https://sylabs.io/docs/)
74+
For full information and documentation please visit [Singularity](https://sylabs.io/docs/).
7475

7576
## How to Create a Singularity Container
7677
So what if you want to create an image from your container and save it for a rainy day?
7778

78-
The instructions are [here](https://apptainer.org/documentation/) for your convenience, read through them to create your own Singularity container and package it into an image!
79+
The instructions are [here](https://apptainer.org/docs/user/latest/build_a_container.html) for your convenience, read through them to create your own Singularity container and package it into an image!
7980

8081
For those that know how docker containers are built, you can build docker containers using the information here and upload them onto docker hub and pulling them using Singularity. Singularity supports all docker images!
8182

8283
## Singularity vs Docker
8384
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.
84-
1. 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.
85-
2. 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.
86-
3. 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.
85+
- 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.
86+
- 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.
87+
- 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.
8788

8889
Good luck with Singularity, and have fun!
8990

0 commit comments

Comments
 (0)