Now that you have a better understanding of containers, you’re ready to get started learning how to run them. The great thing about containers is that they allow you to deploy applications without having to worry about managing servers or installing software. Best of all, it’s easy to launch a container and let it run its job.
For this course, we are going to use an image from the default library, which is the Sylabs SCS public library.
---
name: quickstart-image1-1
---
Example of singularity run.
Easy, right? No need to install anything other than the Singularity container engine and let it go its way. Next, let’s grab a shell and get into the container.
singularity shell library://josue-sylabs/demo/wttr:latest
INFO: Using cached image
Singularity> _
To view detailed information about the container’s operating system, we can display the contents of the /etc/os-release file.
Singularity> cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Now lets exit the shell:
Singularity> exit
exit
In most cases, a container comes with a pre-installed application. The image
creator defines a default command runscript
, which is executed using the run
subcommand. The following example demonstrates the output generated by this
process.
To inspect
the content of a given image and see the runscript
value, first
download or pull
the image and then inspect
using the following steps:
$ singularity pull wttr.sif library://josue-sylabs/demo/wttr:latest
...
$ singularity inspect --runscript wttr.sif
You can see that by default the image launches a common Linux command to pull weather information. Another notable feature of Singularity is its ability to execute images directly without explicitly invoking the Singularity command. You can also easily pull any image from Docker Hub and convert it to the SIF format.
$ singularity pull ubuntu.sif docker://ubuntu
$ ./ubuntu.sif
Singularity> whoami
josue
Singularity> ps
PID TTY TIME CMD
157430 pts/0 00:00:00 bash
158145 pts/0 00:00:00 starter-suid
158164 pts/0 00:00:00 bash
158187 pts/0 00:00:00 ps
Note that immediately after executing ./ubuntu.sif
a Bash shell is created and
ready to accept further commands.
Docker Hub limits its downloads, You can avoid the limit by logging in with a
username and password using the `singularity docker login` command:
```bash
singularity remote login --username username docker://docker.io`
Password / Token:
INFO: Token stored in /home/josue/.singularity/remote.yaml
```
In SingularityCE, a container running a service in the background is called an “instance,” to distinguish it from the default mode where containers run in the foreground.
Instances are just another name for running containers that are operating in the background, typically performing tasks or running services like web servers. These services are often configured to function in detached or daemon mode, allowing the container to run unobtrusively.
We will delve deeper into instances in a later lab.