@@ -18,15 +18,15 @@ bibliography: paper.bib
1818
1919# Summary
2020
21- Singularity Compose is an orchestration tool for management of Singularity containers .
21+ Singularity Compose is an orchestration tool for Singularity container instances .
2222
2323![ Singularity Compose] ( singularity-compose.png )
2424
2525The Singularity container technology started to become popular in 2016,
2626as it offered a more secure option to run encapsulated environments [ @Kurtzer2017-xj ] .
27- Traditionally, this meant that Singularity users could run an entrypoint built into the container
27+ Traditionally, this meant that Singularity users could run an script built into the container
2828(called a runscript), execute a custom command, or shell into a container.
29- Unlike Docker, these basic interactions simply interacted with processes in the
29+ Unlike Docker [ @ Merkel2014-da ] , these basic interactions simply interacted with processes in the
3030foreground (e.g., running a script and exiting) and were not appropriate to run
3131background services. This was a task for container instances [ @SingularityInstances ] .
3232
@@ -37,14 +37,14 @@ Examples of services include databases, web servers, and associated applications
3737that interact with them. While a container technology can provide command line
3838and other programmatic interfaces for interaction with instances, what is also needed
3939is a configuration file for orchestration and customization of several instances.
40- For sibling container technology Docker, Docker Compose was developed
40+ For sibling container technology Docker, Docker Compose [ @ DockerCompose ] was developed
4141for this purpose. For local and production usage, the user could create a ` docker-compose.yml `
4242file to define services, volumes, ports exposed, and other customizations to networking and environment
43- [ @DockerCompose ] . There was strong incentive for the development of such a tool.
44- Docker Compose existed before Kubernetes was available in the middle of 2015 [ @Wikipedia_contributors2019-bw] .
43+ [ @DockerCompose ] . Notably, there was strong incentive for the development of such a tool,
44+ because Docker Compose existed before Kubernetes was available in the middle of 2015 [ @Wikipedia_contributors2019-bw] .
4545
46- No equivalent orchestration tool has been created for Singularity container
47- instances until now . While Singularity has empowered enterprise users to run
46+ No equivalent orchestration tool was created for Singularity container
47+ instances. While Singularity has empowered enterprise users to run
4848services via platforms such as Kubernetes [ @Meyer2019-sd ] , these platforms come
4949with privilege. It is often the case that a production Kubernetes cluster is not
5050readily available to a user via his or her institution, or that the user
@@ -61,37 +61,66 @@ to exist. As the need is unfulfilled, it is the responsibility of the open sourc
6161
6262## Singularity Compose
6363
64- Singularity Compose [ @ SingularityCompose ] is the solution for this niche group of non enterprise users
65- that want to easily create a configuration file to control creation and interaction
66- of services provided by Singularity container instances. It mirrors the format
67- of the ` docker-compose.yml ` file with a ` singularity-compose.yml ` , and allows
68- the user to define one or more container services, optionally with exposed ports
69- to the host. Akin to docker-compose, the user can easily define volumes to be bound
70- to each instance, along with ports to be exposed, and a container binary
71- to build or pull from a remote resource. Custom scripts can also be defined to
64+ The solution for orchestration of container instances from the open source
65+ community is Singularity Compose [ @ SingularityCompose ] . Singularity Compose
66+ is software for non enterprise users to easily create a configuration file to
67+ control creation and interaction of Singularity container instances.
68+ It allows for the creation of a ` singularity-compose.yml ` file, in which
69+ the user can define one or more container services, optionally with exposed ports
70+ and volumes on the host. The user can easily define a container binary
71+ to build or pull from a remote resource, along with custom scripts to
7272run after creation of the instances. Singularity Compose handles designation
7373of addresses on a local bridge network for each container, and creation of
74- resource files to bind to the container to "see" one another related to hostnames
75- and networking. Importantly, by way of adding a Singularity Compose to a repository,
74+ resource files to bind to the containers to "see" one another.
75+ Importantly, by way of adding a Singularity Compose to a repository,
7676a user is ensuring not just reproducibility of a container recipe, but also
77- reproducibility of it's build and creation of services. For example, a
78- sequence of steps for a single container to build it, assign an address, create networking
79- files, and then start an instance might look like this:
77+ reproducibility of it's build and creation of services. For example, a simplified
78+ version of a sequence of steps to build two containers and bring them up
79+ as instances might look like this:
8080
8181``` bash
8282$ sudo singularity build app/app.sif app/Singularity
83+ $ sudo singularity build nginx/nginx.sif nginx/Singularity.nginx
84+
85+ $ singularity instance start \
86+ --bind nginx.conf:/etc/nginx/conf.d/default.conf \
87+ --bind nginx/uwsgi_params.par:/etc/nginx/uwsgi_params.par \
88+ --bind nginx/cache:/var/cache/nginx \
89+ --bind nginx/run:/var/run \
90+ --bind app:/code \
91+ --bind static:/var/www/static \
92+ --bind images:/var/www/images \
93+ --bind etc.hosts:/etc/hosts \
94+ --net --network-args " portmap=80:80/tcp" --network-args " IP=10.22.0.2" \
95+ --hostname nginx --writable-tmpfs nginx/nginx.sif nginx
96+
8397$ singularity instance start \
84- --bind etc.hosts:/etc/hosts \
85- --net --network-args " portmap=80:80/tcp" --network-args " IP=10.22.0.2" \
86- --hostname app \
87- --writable-tmpfs app.sif app
98+ --bind app:/code \
99+ --bind static:/var/www/static \
100+ --bind images:/var/www/images \
101+ --bind etc.hosts:/etc/hosts \
102+ --net --network-args " portmap=8000:8000/tcp" --network-args " IP=10.22.0.3" \
103+ --hostname app --writable-tmpfs app/app.sif app
104+
105+ $ singularity instance list
88106```
89107
90- In the above command, we've already generated the ` etc.hosts ` file that defines
91- hostnames and addresses for other instances, along with a hostname ` app ` for
92- the container we are starting. If we are running three services, we might need
93- to do this three times, and be mindful of binds, ports, and additional arguments
94- for each. With Singularity Compose, the user writes a ` singularity-compose.yml `
108+ This is a complicated set of commands. In the above commands, we
109+ first build the two containers. There are no checks here if the recipes
110+ exist, or if the containers themselves already exist.
111+ We then start instances for them. If we save these commands in a file,
112+ we need to consistently hard code the paths to the container binaries,
113+ along with the ip addresses, hostnames, and volumes. There are no checks
114+ done before attempting the creation if the volumes meant to be bound
115+ actually exist. We also take for granted that we've already generated an
116+ ` etc.hosts ` file to bind to the container at ` /etc/hosts ` , which will
117+ define the container instances to have the same names supplied with ` --hostname `
118+ so that instances can "see" one another. For the networking, we have
119+ to be mindful of the default bridge provided by Singularity, along with how
120+ to specify networking arguments under different conditions. This entire practice
121+ is clearly tedious. For a user to constantly need to generate and then
122+ re-issue these commands, it's not a comfortable workflow. However,
123+ with Singularity Compose, the user writes a ` singularity-compose.yml `
95124file once:
96125
97126``` yaml
@@ -125,7 +154,8 @@ instances:
125154 - 8000:8000
126155` ` `
127156
128- And then can easily build all non-existing containers, and bring up all services
157+ And then can much more readily see and reproduce generation of the same services.
158+ The user can easily build all non-existing containers, and bring up all services
129159with one command:
130160
131161` ` ` bash
0 commit comments