125 | lolcat home page:
126 | Report lolcat translation bugs to
127 | ```
128 |
129 | Once you understand how it works, remove (or comment) the echo line in `lolcow/libexec/lolcow.sh` and even things like this should work without a hitch:
130 |
131 | ```
132 | $ fortune | cowsay -n | lolcat
133 | ___________________________________________________________
134 | < You never hesitate to tackle the most difficult problems. >
135 | -----------------------------------------------------------
136 | \ ^__^
137 | \ (oo)\_______
138 | (__)\ )\/\
139 | ||----w |
140 | || ||
141 | ```
142 |
143 | ---
144 | **NOTE**
145 |
146 | If you have too much time on your hands, you might try linking things like `sh`, `bash`, `ls`, or `cd` to the container wrapper script. But otherwise **don't**... because it will cause you a lot of trouble. :-)
147 |
148 | ---
149 | <- [previous](/06-runscript) - [home](https://singularity-tutorial.github.io/) - [next](/08-misc) ->
--------------------------------------------------------------------------------
/08-misc/README.md:
--------------------------------------------------------------------------------
1 | <- [previous](/07-fake-installation) - [home](https://singularity-tutorial.github.io/)
2 |
3 | ---
4 | # Miscellaneous Topics and FAQs
5 |
6 | ## X11 and OpenGL
7 |
8 | You can use Singularity containers to display graphics through common protocols. To do this, you need to install the proper graphics stack within the Singularity container. For instance if you want to display X11 graphics you must install `xorg` within your container. In an Ubuntu container the command would look like this.
9 |
10 | ```
11 | $ apt-get install xorg
12 | ```
13 |
14 | ## GPU computing
15 |
16 | In Singularity v2.3+ the experimental `--nv` option will look for NVIDIA libraries on the host system and automatically bind mount them to the container so that GPUs work seamlessly.
17 |
18 | ## Using the network on the host system
19 |
20 | Network ports on the host system are accessible from within the container and work seamlessly. For example, you could install ipython within a container, start a jupyter notebook instance, and then connect to that instance using a browser running outside of the container on the host system or from another host.
21 |
22 | ## A note on SUID programs and daemons
23 |
24 | Some programs need root privileges to run. These often include services or daemons that start via the `init.d` or `system.d` systems and run in the background. For instance, `sshd` the ssh daemon that listens on port 22 and allows another user to connect to your computer requires root privileges. You will not be able to run it in a container unless you start the container as root.
25 |
26 | Other programs may set the SUID bit or capabilities to run as root or with elevated privileges without your knowledge. For instance, the well-known `ping` program actually runs with elevated privileges (and needs to since it sets up a raw network socket). This program will not run in a container unless you are root in the container.
27 |
28 |
29 | ## Long-running Instances
30 |
31 | Up to now all of our examples have run Singularity containers in the foreground. But what if you want to run a service like a web server or a database in a Singularity container in the background?
32 |
33 | ### lolcow (useless) example
34 | In Singularity v2.4+, you can use the [`instance` command group](http://singularity.lbl.gov/docs-instances) to start and control container instances that run in the background. To demonstrate, let's start an instance of our `lolcow.simg` container running in the background.
35 |
36 | ```
37 | $ singularity instance.start lolcow.simg cow1
38 | ```
39 |
40 | We can use the `instance.list` command to show the instances that are currently running.
41 |
42 | ```
43 | $ singularity instance.list
44 | DAEMON NAME PID CONTAINER IMAGE
45 | cow1 10794 /home/dave/lolcow.simg
46 | ```
47 |
48 | We can connect to running instances using the `instance://` URI like so:
49 |
50 | ```
51 | $ singularity shell instance://cow1
52 | Singularity: Invoking an interactive shell within container...
53 |
54 | Singularity lolcow.simg:~> ps -ef
55 | UID PID PPID C STIME TTY TIME CMD
56 | dave 1 0 0 19:05 ? 00:00:00 singularity-instance: dave [cow1]
57 | dave 3 0 0 19:06 pts/0 00:00:00 /bin/bash --norc
58 | dave 4 3 0 19:06 pts/0 00:00:00 ps -ef
59 |
60 | Singularity lolcow.simg:~> exit
61 | ```
62 |
63 | Note that we've entered a new PID namespace, so that the `singularity-instance` process has PID number 1.
64 |
65 | You can start multiple instances running in the background, as long as you give them unique names.
66 |
67 | ```
68 | $ singularity instance.start lolcow.simg cow2
69 |
70 | $ singularity instance.start lolcow.simg cow3
71 |
72 | $ singularity instance.list
73 | DAEMON NAME PID CONTAINER IMAGE
74 | cow1 10794 /home/dave/lolcow.simg
75 | cow2 10855 /home/dave/lolcow.simg
76 | cow3 10885 /home/dave/lolcow.simg
77 | ```
78 |
79 | You can stop individual instances using their unique names or stop all instances with the `--all` option.
80 |
81 | ```
82 | $ singularity instance.stop cow1
83 | Stopping cow1 instance of /home/dave/lolcow.simg (PID=10794)
84 |
85 | $ singularity instance.stop --all
86 | Stopping cow2 instance of /home/dave/lolcow.simg (PID=10855)
87 | Stopping cow3 instance of /home/dave/lolcow.simg (PID=10885)
88 | ```
89 |
90 | ### nginx (useful) example
91 |
92 | These examples are not very useful because `lolcow.simg` doesn't run any services. Let's extend the example to something useful by running a local nginx web server in the background. This command will download the official nginx image from Docker Hub and start it in a background instance called "web". (The commands need to be executed as root so that nginx can run with the privileges it needs.)
93 |
94 | ```
95 | $ sudo singularity instance.start docker://nginx web
96 | Docker image path: index.docker.io/library/nginx:latest
97 | Cache folder set to /root/.singularity/docker
98 | [3/3] |===================================| 100.0%
99 | Creating container runtime...
100 |
101 | $ sudo singularity instance.list
102 | DAEMON NAME PID CONTAINER IMAGE
103 | web 15379 /tmp/.singularity-runtime.MBzI4Hus/nginx
104 | ```
105 |
106 | Now to start nginx running in the instance called web.
107 |
108 | ```
109 | $ sudo singularity exec instance://web nginx
110 | ```
111 |
112 | Now we have an nginx web server running on our localhost. We can verify that it is running with `curl`.
113 |
114 | ```
115 | $ curl localhost
116 | 127.0.0.1 - - [02/Nov/2017:19:20:39 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.52.1" "-"
117 |
118 |
119 |
120 | Welcome to nginx!
121 |
128 |
129 |
130 | Welcome to nginx!
131 | If you see this page, the nginx web server is successfully installed and
132 | working. Further configuration is required.
133 |
134 | For online documentation and support please refer to
135 | nginx.org.
136 | Commercial support is available at
137 | nginx.com.
138 |
139 | Thank you for using nginx.
140 |
141 |
142 | ```
143 |
144 | When finished, don't forget to stop all running instances like so:
145 |
146 | ```
147 | $ sudo singularity instance.stop --all
148 | ```
149 |
150 | ---
151 | <- [previous](/07-fake-installation) - [home](https://singularity-tutorial.github.io/)
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [home](https://singularity-tutorial.github.io/) - [next](/00-introduction) ->
2 |
3 | ---
4 | # Creating and running software containers with Singularity
5 |
6 | ### How to use [Singularity](https://sylabs.io/guides/latest/user-guide/)!
7 |
8 |
9 | This is an introductory workshop on Singularity. It was originally taught by [David Godlove](https://github.com/GodloveD) at the [NIH HPC](https://hpc.nih.gov/), but the content has since been adapted to a general audience. For more information about the topics covered here, see the following:
10 |
11 | - [Singularity Home](https://sylabs.io/singularity/)
12 | - [Singularity on GitHub](https://github.com/singularityware/singularity)
13 | - [Singularity on Google Groups](https://groups.google.com/a/lbl.gov/forum/#!forum/singularity)
14 | - [Singularity at the NIH HPC](https://hpc.nih.gov/apps/singularity.html)
15 | - [Docker documentation](https://docs.docker.com/)
16 | - [Singularity Container Services](https://cloud.sylabs.io/home)
17 | - [Docker Hub](https://hub.docker.com/)
18 |
19 | ## Table of Contents
20 |
21 | - [Introduction](/00-introduction)
22 | - [Installing Singularity](/01-installation)
23 | - [Downloading and Interacting with Containers](/02-basic-usage)
24 | - [Building a Basic Container](/03-building)
25 | - [The Singularity Ecosystem](/04-the-ecosystem)
26 | - [Accessing Host Files with Bind Mounts](/05-bind-mounts)
27 | - [The Runscript: Making Containerized Apps Behave Like Normal Apps](/06-runscript)
28 | - [Faking a Native Installation within a Singularity Container](/07-fake-installation)
29 | - [Miscellaneous Topics and FAQs](/08-misc)
30 |
31 | ---
32 | [home](https://singularity-tutorial.github.io/) - [next](/00-introduction) ->
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------