-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHow to set up Singularity on Ubuntu 18.04
100 lines (76 loc) · 3.13 KB
/
How to set up Singularity on Ubuntu 18.04
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
How to set up Singularity on Ubuntu 18.04
Sources used:
https://sylabs.io/guides/3.5/admin-guide/installation.html#installation-on-linux
https://singularity-tutorial.github.io/
https://stackoverflow.com/questions/42186003/how-to-uninstall-golang
https://golang.org/doc/install
install dependencies:
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
download go: https://golang.org/dl/
sudo tar -C /opt/ -xzf go1.14.linux-amd64.tar.gz
export PATH=$PATH:/opt/go/bin
go version (should be the version from above, if not you might have to: sudo apt-get remove golang-go && sudo apt-get remove --auto-remove golang-go)
Test go compiler:
nano hello.go
package main
import "fmt"
func main() { fmt.Printf("hello, world\n") }
go build hello.go
./hello
Singularity version 3.5.3-1.1.el7 is currently on the cluster:
export VERSION=3.5.3 && \
wget https://github.com/sylabs/singularity/releases/download/v${VERSION}/singularity-${VERSION}.tar.gz && \
tar -xzf singularity-${VERSION}.tar.gz && \
cd singularity
./mconfig && \
make -C ./builddir && \
sudo make -C ./builddir install
Make a Singularity container
----------------------------
Run a docker container with Singularity
singularity run docker://godlovedc/lolcow
for the next steps work on a local drive, network drives do not work! (use: df -h to find out if necessary):
make a file:
nano Singularity
with the following content:
BootStrap: debootstrap
OSVersion: trusty
MirrorURL: http://us.archive.ubuntu.com/ubuntu/
%runscript
echo "This is what happens when you execute the container..."
%post
echo "Hello from inside the container"
sed -i 's/$/ universe/' /etc/apt/sources.list
apt-get update
apt-get -y install vim fortune cowsay lolcat
apt-get clean
%environment
export PATH=/usr/games:$PATH
export LC_ALL=C
Create a sandbox container:
sudo /usr/local/bin/singularity build --sandbox lolcow Singularity
Edit the sandbox container, install stuff, try out etc.
sudo singularity shell --writable lolcow
Create a full container:
sudo /usr/local/bin/singularity build lolcow.simg Singularity
See the recipe file used to create the container:
singularity inspect --deffile lolcow.simg
Run the container with arguments:
singularity exec lolcow.simg cowsay 'How did you get out of the container?'
Pass i/o around (1):
echo "The grass is always greener over the septic tank" > input
cat input | singularity exec lolcow.simg cowsay > output
cat output
Pass i/o around (2):
./lolcow.simg #leads to the output 'This is what happens when you run the container...'
Change the %runscript section to e.g.:
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Please provide an input and an output file."
exit 1
fi
cat $1 | cowsay > $2
./lolcow.simg input output.txt
If you want to copy files to the container add a $files section in the container description, which copies the designed file or directory into a specified location in the container
%files
/groups/scicompsoft/home/preibischs/software/jdk1.8.0_112 jdk