Skip to content

Harmonize NIH repo with this one #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 115 commits into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
2bb66c5
initial commit!
GodloveD Jun 4, 2017
573f7dd
first fix!
GodloveD Jun 4, 2017
9ea25d0
few teaks
GodloveD Jun 4, 2017
b7c64c0
few teaks
GodloveD Jun 4, 2017
5f1a002
trying to add colorized output
GodloveD Jun 4, 2017
2e717f7
trying to add colorized output
GodloveD Jun 4, 2017
c501b54
trying to add colorized output
GodloveD Jun 4, 2017
9760580
quit trying to add colorized output
GodloveD Jun 4, 2017
13027a6
quit trying to add colorized output
GodloveD Jun 4, 2017
1b14207
finishing first section
GodloveD Jun 4, 2017
d0dfc81
finishing first section
GodloveD Jun 4, 2017
d6e6ecc
Started second hour section
GodloveD Jun 5, 2017
1201340
working on second hour section
GodloveD Jun 5, 2017
7309850
trying to add content for hour 3
GodloveD Jun 6, 2017
03073dc
some tweaks
GodloveD Jun 7, 2017
2a4dea1
rounding out hour 2 content
GodloveD Jun 7, 2017
4beba38
rounding out hour 2 content
GodloveD Jun 7, 2017
ebd9a65
rounding out hour 2 content
GodloveD Jun 7, 2017
e0a0dc7
rounding out hour 3 content
GodloveD Jun 7, 2017
ec6f948
rounding out hour 3 content
GodloveD Jun 7, 2017
c7152b0
rounding out hour 3 content
GodloveD Jun 7, 2017
26f3520
finishing up
GodloveD Jun 7, 2017
f91ebfa
finishing up
GodloveD Jun 7, 2017
d9e2744
trying to build rnaseq
Jun 7, 2017
69bbc6d
WR's excellennt updates
GodloveD Jun 8, 2017
fab8115
It's vs Its
0xaf1f Jun 20, 2017
f7fd5dd
your and you're
0xaf1f Jun 20, 2017
9d3b734
updating tutorial for 2.4
GodloveD Nov 1, 2017
3c9aac1
reverting accidental changes
GodloveD Nov 1, 2017
42ed151
deleting rnaseq example
GodloveD Nov 1, 2017
b611d55
added instance section
GodloveD Nov 2, 2017
bcbd0ee
fixing a link
GodloveD Nov 2, 2017
9802967
fixing a link
GodloveD Nov 2, 2017
5538886
fixing a link
GodloveD Nov 2, 2017
ed11d09
going through the tutorial making fixes
GodloveD Nov 2, 2017
3459620
going through the tutorial making fixes
GodloveD Nov 2, 2017
5b5f8de
going through the tutorial making fixes
GodloveD Nov 2, 2017
f08a388
going through the tutorial making fixes
GodloveD Nov 2, 2017
30ddd0d
going through the tutorial making fixes
GodloveD Nov 2, 2017
0b240c8
going through the tutorial making fixes
GodloveD Nov 2, 2017
f307843
going through the tutorial making fixes
GodloveD Nov 2, 2017
58aa2cb
going through the tutorial making fixes
GodloveD Nov 2, 2017
acacfb6
going through the tutorial making fixes
GodloveD Nov 2, 2017
d83bdf2
going through the tutorial making fixes
GodloveD Nov 2, 2017
710ae4c
going through the tutorial making fixes
GodloveD Nov 2, 2017
5ec8c34
going through the tutorial making fixes
GodloveD Nov 2, 2017
f54e1ab
going through the tutorial making fixes
GodloveD Nov 2, 2017
a68df92
going through the tutorial making fixes
GodloveD Nov 2, 2017
821c991
going through the tutorial making fixes
GodloveD Nov 2, 2017
a68fcba
going through the tutorial making fixes
GodloveD Nov 2, 2017
e650e77
going through the tutorial making fixes
GodloveD Nov 2, 2017
e4b2e43
going through the tutorial making fixes
GodloveD Nov 2, 2017
4257c3d
going through the tutorial making fixes
GodloveD Nov 2, 2017
3a836bb
going through the tutorial making fixes
GodloveD Nov 2, 2017
7eccbad
going through the tutorial making fixes
GodloveD Nov 2, 2017
3c13cf2
going through the tutorial making fixes
GodloveD Nov 2, 2017
51cdce7
going through the tutorial making fixes
GodloveD Nov 2, 2017
1ae8ec2
going through the tutorial making fixes
GodloveD Nov 2, 2017
a49aef6
going through the tutorial making fixes
GodloveD Nov 2, 2017
d9b89c9
going through the tutorial making fixes
GodloveD Nov 2, 2017
0b12f7b
going through the tutorial making fixes
GodloveD Nov 2, 2017
bb40fc7
going through the tutorial making fixes
GodloveD Nov 2, 2017
2a53482
going through the tutorial making fixes
GodloveD Nov 2, 2017
953ea68
going through the tutorial making fixes
GodloveD Nov 2, 2017
37f9e8b
going through the tutorial making fixes
GodloveD Nov 2, 2017
c76b811
going through the tutorial making fixes
GodloveD Nov 2, 2017
39a4274
going through the tutorial making fixes
GodloveD Nov 2, 2017
6c6704f
going through the tutorial making fixes
GodloveD Nov 2, 2017
5a0445a
going through the tutorial making fixes
GodloveD Nov 2, 2017
733c83f
going through the tutorial making fixes
GodloveD Nov 2, 2017
45b0b50
Merge branch 'godlovedc/master'
0xaf1f Nov 2, 2017
cc30d5e
Changes to apt-get flags
0xaf1f Nov 2, 2017
2b7c94c
missed stray flag to apt-get update
0xaf1f Nov 2, 2017
2a83c80
Improve meta-cowsay
0xaf1f Nov 2, 2017
01dbb77
Fix typo (s/HCP/HPC)
0xaf1f Nov 3, 2017
519ee1b
Adjust working directory setup
0xaf1f Nov 4, 2017
c038752
First parts of tutorial: Correct prompt when using the container inte…
0xaf1f Nov 4, 2017
449ab62
Fix more prompts
0xaf1f Nov 4, 2017
4e5b6d4
Remove dh-autoreconf from initialization step
0xaf1f Nov 6, 2017
ad30b6f
Clarify runscript section header
0xaf1f Nov 6, 2017
a491629
Make definition files consistent
0xaf1f Nov 6, 2017
1e9fcdb
Move discussion of instances to an auxiliary document
0xaf1f Nov 6, 2017
e953abe
untabify
0xaf1f Nov 6, 2017
82a766b
s/sez/txt/
0xaf1f Nov 6, 2017
d222c54
Revise the runscript example to allow passing through options to cowsay
0xaf1f Nov 6, 2017
b173185
simplify example of piping within singularity exec
0xaf1f Nov 6, 2017
289e025
s|/home/$USER|$HOME|
0xaf1f Nov 15, 2017
ea240b9
Add link to list of HPC sites with Singularity installations
0xaf1f Jan 25, 2018
f668e17
Add link to Docker security page
0xaf1f Jan 25, 2018
cf31453
Add installation of squashfs-tools to the installation section
0xaf1f Feb 6, 2018
67ff045
Use singularity 2.4.2
0xaf1f Feb 6, 2018
8729028
Fix the developer's example definition file before doing anything else
0xaf1f Feb 6, 2018
b48095e
Use Ubuntu 16.04 rather than 14.04
0xaf1f Feb 6, 2018
3de24b3
Correct output of singularity inspect
0xaf1f Feb 6, 2018
57a33ad
modularize the tutorial
0xaf1f Jul 20, 2018
1cb3a83
integrate a note from misc into the i/o section
0xaf1f Jul 20, 2018
9d64fa8
smooth edges after breaking the monolithic document
0xaf1f Jul 20, 2018
ee82071
Update to Singularity 2.5.2
0xaf1f Jul 26, 2018
2a16414
Use debian instead of ubuntu for container base
0xaf1f Jul 26, 2018
a25de7f
Improve example of privilege escalation failure
0xaf1f Jul 26, 2018
f240b4c
Append (rather than prepend) /usr/games to PATH in container
0xaf1f Jul 26, 2018
759b1eb
fix typo in container name
0xaf1f Jul 26, 2018
1e91919
the-hubs: add mention of singularity pull
0xaf1f Jul 26, 2018
6e0522b
installation: make sure to include libarchive, a new dependency
0xaf1f Jul 30, 2018
5116d02
updated installation procedure for 3.5.3
GodloveD Feb 26, 2020
03e487b
fixing up building tutorial for 3.5
GodloveD Feb 28, 2020
a703960
Rearranging content to prioritize _using_ pre-built containers before
GodloveD Mar 1, 2020
95bc5d6
updates to the building docs
GodloveD Mar 1, 2020
bc63da0
completely changed the sections about online resources
GodloveD Mar 2, 2020
5d8de7c
redoing ordering and content of bind-mount section
GodloveD Mar 2, 2020
9924dfa
simplifiying the runscript section
GodloveD Mar 2, 2020
9190c2f
added a tutorial for faking installations.
GodloveD Mar 2, 2020
fa39fe4
polishing things up a bit
GodloveD Mar 6, 2020
5ea28c0
few touch ups
GodloveD Mar 17, 2020
4d36189
harmonizing changes here with those created seperately within NIH-HPC…
GodloveD Jun 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions 00-installation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Installing Singularity
Here we will install the latest tagged release from [GitHub](https://github.com/sylabs/singularity/releases). If you prefer to install a different version or to install Singularity in a different location, see these [Singularity docs](https://sylabs.io/guides/3.5/admin-guide/installation.html).

We're going to compile Singularity from source code. First we'll need to make sure we have some development tools and libraries installed so that we can do that. On Ubuntu, run these commands to make sure you have all the necessary packages installed.

```
$ sudo apt-get update

$ sudo apt-get install -y build-essential libssl-dev uuid-dev libgpgme11-dev \
squashfs-tools libseccomp-dev wget pkg-config git cryptsetup debootstrap
```

On CentOS, these commmands should get you up to speed.

```
$ sudo yum -y update

$ sudo yum -y groupinstall 'Development Tools'

$ sudo yum -y install wget epel-release

$ sudo yum -y install debootstrap.noarch squashfs-tools openssl-devel \
libuuid-devel gpgme-devel libseccomp-devel cryptsetup-luks
```

Singularity v3.0 was completely re-written in [Go](https://golang.org/). We will need to install the Go language so that we can compile Singularity. This procedure consists of downloading Go in a compressed archive, extracting it to `/usr/local/go` and placing the appropriate directory in our `PATH`. For more details, check out the [Go Downloads page](https://golang.org/dl/).

```
$ wget https://dl.google.com/go/go1.13.linux-amd64.tar.gz

$ sudo tar --directory=/usr/local -xzvf go1.13.linux-amd64.tar.gz

$ export PATH=/usr/local/go/bin:$PATH
```

Next we'll download a compressed archive of the source code (using the the `wget` command). Then we'll extract the source code from the archive (with the `tar` command).

```
$ wget https://github.com/singularityware/singularity/releases/download/v3.5.3/singularity-3.5.3.tar.gz

$ tar -xzvf singularity-3.5.3.tar.gz
```

Finally it's time to build and install!

```
$ cd singularity

$ ./mconfig

$ cd builddir

$ make

$ sudo make install
```

If you want support for tab completion of Singularity commands, you need to source the appropriate file and add it to the bash completion directory in `/etc` so that it will be sourced automatically when you start another shell.

```
$ . etc/bash_completion.d/singularity

$ sudo cp etc/bash_completion.d/singularity /etc/bash_completion.d/
```

If everything went according to plan, you now have a working installation of Singularity.
Simply typing `singularity` will give you a summary of all the commands you can use.
Typing `singularity help <command>` will give you more detailed information about running an individual command.

You can test your installation like so:

```
$ singularity run library://godlovedc/funny/lolcow
```

You should see something like the following.

```
INFO: Downloading library image
_______________________________________
/ Excellent day for putting Slinkies on \
\ an escalator. /
---------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```

Your cow will likely say something different (and be more colorful), but as long as you see a cow your installation is working properly.

This command downloads and "runs" a container from [Singularity Container Library](https://cloud.sylabs.io/library). (We'll be talking more about what it means to "run" a container later on in the class.)

In a following exercise, we will learn how to build a similar container from scratch. But right now, we are going to use this container to execute a bunch of basic commands and just get a feel for what it's like to use Singularity.
266 changes: 266 additions & 0 deletions 01-basic-usage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
# Downloading and interacting with containers

This section will be useful for container consumers. (i.e. those who really just want to use containers somebody else built.) The next chapter will explore topics more geared toward container producers (i.e. those who want/need to build containers from scratch).

You can find pre-built containers in lots of places. Singularity can convert and run containers in many different formats, including those built by Docker.

In this class, we'll be using containers from:

- [The Singularity Container Library](https://cloud.sylabs.io/library), developed and maintained by [Sylabs](https://sylabs.io/)
- [Docker Hub](https://hub.docker.com/), developed and maintained by [Docker](https://www.docker.com/)

There are lots of other places to find pre-build containers too. Here are some of the more popular ones:

- [Singularity Hub](https://singularity-hub.org/), an early collaboration between Stanford University and the Singularity community
- [Quay.io](https://quay.io/), developed and maintained by Red Hat
- [NGC](https://ngc.nvidia.com/catalog/all?orderBy=modifiedDESC&pageNumber=3&query=&quickFilter=&filters=), developed and maintained by NVIDIA
- [BioContainers](https://biocontainers.pro/#/registry), develped and maintained by the Bioconda group
- Cloud providers like Amazon AWS, Microsoft Azure, and Google cloud also have container registries that can work with Singularity

## Downloading containers

In the last section, we validated our Singularity installation by "running" a container from the Container Library. Let's download that container using the `pull` command.

```
$ cd ~

$ singularity pull library://godlovedc/funny/lolcow
```

You'll see a warning about running `singularity verify` to make sure that the container is trusted. We'll talk more about that later.

For now, notice that you have a new file in your current working directory called `lolcow_latest.sif`

```
$ ls lolcow_latest.sif
lolcow_latest.sif
```

This is your container. Or more precisely, it is a Singularity Image Format (SIF) file containing an image of a root level filesystem. This image is mounted to your host filesystem (in a new "mount namespace") and then entered when you run a Singularity command.

Note that you can download the Docker version of this same container from Docker Hub with the following command:

```
$ singularity pull docker://godlovedc/lolcow
```

Doing so may produce an error if the container already exists.

## Entering containers with `shell`

Now let's enter our new container and look around. We can do so with the `shell` command.

```
$ singularity shell lolcow_latest.sif
```

Depending on the environment of your host system you may see your shell prompt change. Let's look at what OS is running inside the container.

```
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.5 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
```

No matter what OS is running on your host, your container is running Ubuntu 16.04 (Xenial Xerus)!

---
**NOTE**

In general, the Singularity action commands (like `shell`, `run`, and `exec`) are expected to work with URIs like `library://` and `docker://` the same as they would work with a local image.

---


Let's try a few more commands:

```
Singularity> whoami
dave

Singularity> hostname
hal-9000
```

This is one of the core features of Singularity that makes it so attractive from a security and usability standpoint. The user remains the same inside and outside of the container.

Regardless of whether or not the program `cowsay` is installed on your host system, you have access to it now because it is installed inside of the container:

```
Singularity> which cowsay
/usr/games/cowsay

Singularity> cowsay moo
_____
< moo >
-----
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```

We'll be getting a lot of mileage out of this silly little program as we explore Linux containers.

This is the command that is executed when the container actually "runs":

```
Singularity> fortune | cowsay | lolcat
____________________________________
/ A horse! A horse! My kingdom for a \
| horse! |
| |
\ -- Wm. Shakespeare, "Richard III" /
------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```

More on "running" the container in a minute. For now, don't forget to `exit` the container when you are finished playing!

```
Singularity> exit
exit
```

## Executing containerized commands with `exec`

Using the `exec` command, we can run commands within the container from the host system.

```
$ singularity exec lolcow_latest.sif cowsay 'How did you get out of the container?'
_______________________________________
< How did you get out of the container? >
---------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```

In this example, singularity entered the container, ran the `cowsay` command with supplied arguments, displayed the standard output on our host system terminal, and then exited.

## "Running" a container with (and without) `run`

As mentioned several times you can "run" a container like so:

```
$ singularity run lolcow_latest.sif
_________________________________________
/ Q: How many Bell Labs Vice Presidents \
| does it take to change a light bulb? A: |
| That's proprietary information. Answer |
| available from AT&T on payment of |
\ license fee (binary only). /
-----------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```

So what actually happens when you run a container? There is a special file within the container called a `runscript` that is executed when a container is run. You can see this (and other meta-data about the container) using the inspect command.

```
$ singularity inspect --runscript lolcow_latest.sif
#!/bin/sh

fortune | cowsay | lolcat
```

In this case the `runscript` consists of three simple commands with the output of each command piped to the subsequent command.

Because Singularity containers have pre-defined actions that they must carry out when run, they are actually executable. Note the default permissions when you download or build a container:

```
$ ls -l lolcow_latest.sif
-rwxr-xr-x 1 student student 93574075 Feb 28 23:02 lolcow_latest.sif
```

This allows you to run execute a container like so:

```
$ ./lolcow_latest.sif
________________________________________
/ It is by the fortune of God that, in \
| this country, we have three benefits: |
| freedom of speech, freedom of thought, |
| and the wisdom never to use either. |
| |
\ -- Mark Twain /
----------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```
As we shall see later, this nifty trick can makes it easy to forget your applications are containerized and just run them like any old program.

## Pipes and redirection

Singularity does not try to isolate your container completely from the host system. This allows you to do some interesting things. For instance, you can use pipes and redirection to blur the lines between the container and the host system.

```
$ singularity exec lolcow_latest.sif cowsay moo > cowsaid

$ cat cowsaid
_____
< moo >
-----
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```

We created a file called `cowsaid` in the current working directory with the output of a command that was executed within the container. >_shock and awe_

We can also pipe things _into_ the container (and that is very tricky).

```
$ cat cowsaid | singularity exec lolcow_latest.sif cowsay -n
______________________________
/ _____ \
| < moo > |
| ----- |
| \ ^__^ |
| \ (oo)\_______ |
| (__)\ )\/\ |
| ||----w | |
\ || || /
------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```

We've created a meta-cow (a cow that talks about cows). ;-P

So pipes and redirects work as expected between a container and the host system. If, however, you need to pipe the output of one command in your container to another command in your container, things are slightly more complicated. Pipes and redirects are shell constructs, so if you don't want your host shell to interpret them, you have to hide them from it.

```
$ singularity exec lolcow_latest.sif sh -c "fortune | cowsay | lolcat"
```

The above invokes a new shell, but inside the container, and tells it to run the single command line `fortune | cowsay | lolcat`.

That covers the basics on how to download and use pre-built containers! In the next section we'll start learning how to build your own containers.
Loading