-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathblogger_container_hpc.html
1103 lines (869 loc) · 40.2 KB
/
blogger_container_hpc.html
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<!-- DataTables jQuery -->
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-1.12.0.min.js">
</script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js">
</script>
<script type="text/javascript" class="init">
$(document).ready(function() {
$('table.display').DataTable( { // multi table example use table.display as selector
lengthMenu: [ [ 5, 10, 15, 20, -1 ], [ 5, 10, 15, 20, "All" ] ], // all is coded as -1, thus the double array
pageLength: -1, // YES, can use -1 to display all rows by default
order: [ ] // ie no ordering, show data as they are loaded
//order: [ 0, "desc" ], // descending order https://datatables.net/reference/option/order
} );
} );
</script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.11/css/jquery.dataTables.min.css">
<!-- overwrite some css to my liking -->
<STYLE>
H1, H2, H3, H4 {
/*color: green;*/
padding: 0.1em;
margin-top: 0.2em;
margin-bottom: 0.4em;
font-family: helvetica, arial, lucida, sans-serif;
/*text-align: center;*/
}
H1 {
text-align: center;
background-color: #CCCCCC; /* #BBF0BB; */
font-size: 170%;
font-weight: bolder;
text-transform: uppercase;
; list-style-type: decimal
}
H2 {
background-color: #D0F0D0;
font-size: 150%;
font-variant: small-caps;
text-transform: uppercase;
border-style: solid;
/* text-transform: capitalize; */
; list-style-type: decimal
}
a:link{ color: green; text-decoration: underline; }
a:visited{ color: gray; text-decoration: underline; font-weight: bold; }
a:hover{ color: Red; text-decoration: underline; background-color: #BBF0BB }
/* a:active{ color: Olive; text-decoration: overline; background-color: #334433 } */
table.dataTable tbody td{padding:1px 1px 1px 1px;}
/* table.dataTable.hover tbody tr:hover { background: cyan; } don't work */
/* table.dataTable tbody td:hover { background: magenta; } this one works but don't like it */
table {
width: 100%;
background-color: #ffffff;
border-collapse: collapse;
border-width: 1px;
border-color: #a4a4a4;
border-style: solid;
color: #000000;
}
table td, table th {
border-width: 1px;
border-color: #a4a4a4;
border-style: solid;
padding: 3px;
}
table thead, table tfoot {
background-color: #CCCCCC; /*#BBF0BB; ;*/
}
/* border for code */
PRE.code {
border: #630 1px solid;
color: #630;
padding-left: 0.5em;
}
TT, table.TT { color: green; }
/* reducing margin space of list, as little space in table */
table ol, table ol li {margin-left: 0.4em; padding-left: 0.1em; padding-right: 0.1em; margin-top: 0em; margin-bottom: 0em; list-style: decimal;}
table ul, table ul li {margin-left: 0.4em; padding-left: 0.1em; padding-right: 0.1em; margin-top: 0em; margin-bottom: 0em;}
</STYLE>
</HEAD>
<BODY>
<title>Docker vs Singularity vs Shifter vs UGE Container Edition</title>
<h1>Docker vs Singularity vs Shifter vs UGE Container Edition</h1>
<!-- ################################################################## -->
<!-- ################################################################## -->
<!-- content below can go to blogger, sans tailing /body and /html tags -->
<!-- CSS to format table in blogger where DataTables jQuery is not used to format the table -->
<!--
<style>
table.display {
width: 100%;
background-color: #ffffff;
border-collapse: collapse;
border-width: 2px;
border-color: #00a400;
border-style: solid;
color: #000000;
}
table.display td, table.display th {
border-width: 2px;
border-color: #00a400;
border-style: solid;
padding: 3px;
}
table.display thead, table.display tfoot {
background-color: #00a400;
}
/* border for code */
PRE.code {
border: #630 1px solid;
color: #630;
padding-left: 0.5em;
}
TT, table.TT { color: green; }
/* reducing margin space of list, as little space in table */
table ol, table ol li {margin-left: 0.4em; padding-left: 0.1em; padding-right: 0.1em; margin-top: 0em; margin-bottom: 0em; list-style: decimal;}
table ul, table ul li {margin-left: 0.4em; padding-left: 0.1em; padding-right: 0.1em; margin-top: 0em; margin-bottom: 0em;}
</style>
-->
<!-- HTML Code: Place this code in the document's body (between the 'body' tags) where the table should appear -->
<div dir="ltr" style="text-align: left;" trbidi="on"> </div> <!-- this extra div is needed or title format get messed up in blogger-->
<div dir="ltr" style="text-align: left;" trbidi="on">
Here is a comparison of HPCS Singularity vs NeRSC Shifter. They both bring the benefits of container to the HPC world. As such, both provide very similar features. The subtleties are in their implementation approach. MPI maybe the place with the biggest difference. <BR />
Please comment on the
<A HREF="http://geekyap.blogspot.com/2016/11/docker-vs-singularity-vs-shifter-in-hpc.html#comment">blogger comment section</A>
to improve the doc. Much thanks!
<BR/>
(For large screen avoiding the mangling by blogger, view the working version of this file in <A HREF="https://tin6150.github.io/psg/blogger_container_hpc.html">github</A>.)
<BR />
<BR />
<A NAME="vm_vs_container"></A>
<H4>Oveview of VM vs Docker vs Singularity</H4>
<A HREF="http://www.hpcadvisorycouncil.com/events/2017/stanford-workshop/pdf/GMKurtzer_Singularity_Keynote_Tuesday_02072017.pdf#43">
<IMG SRC="https://tin6150.github.io/psg/fig/vm_vs_container.png" alt="container vs vm stack diagram from GMK keynote slide deck"></IMG></A><BR />
Source: <A HREF="http://www.hpcadvisorycouncil.com/events/2017/stanford-workshop/pdf/GMKurtzer_Singularity_Keynote_Tuesday_02072017.pdf#43">Greg Kurtzer keynote at HPC Advisory Council 2017 @ Stanford</A> <br/>
<br/>
<br/>
<A NAME="tabular_comparison"></A>
<H4>Tabular comparison</H4>
<BR/>
<!--table class="GeneratedTable"-->
<table class="display">
<thead>
<tr>
<th></th>
<th>Docker</th>
<th>Singularity</th>
<th>Shifter</th>
<th>UGE Container Ed.</th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th>Docker</th>
<th>Singularity</th>
<th>Shifter</th>
<th>UGE Container Ed.</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Main problem being addressed</td>
<td>DevOps, microservices. Enterprise applications</td>
<td>
Application portability (single image file, contain all dependencies) <BR>
Reproducibility, run cross platform, provide support for legacy OS and apps.<BR>
</td>
<td>Utilize the large number of docker apps. Provides a way to run them in HPC after a conversion process. It also strip out all the requirements of root so that they are runnable as user process. <BR />
</td>
<td>Running dockers containers in HPC, with UGE managing the docker daemon process (?) </td>
</tr>
<tr>
<td>Interaction w/ Docker</td>
<td></td>
<td>
Singularity work completely independent of Docker. <BR />
It does have ability to import docker images, convert them to singularity images, or run docker container directly<BR />
</td>
<td>
Shifter primary workflow is to pull and convert docker image into shifter image.<BR />
Image Gateway connects to Docker Hub using its build-in functions, docker does not need to be installed.
</td>
<td></td>
</tr>
<tr>
<td>User group of primary focus</td>
<td>Developers/DevOps</td>
<td colspan=2>Scientific Application Users</td>
<td>UGE users</td>
</tr>
<td>Use Case Focus</td>
<td>microservices. Do one small thing alone but does it well. Often daemon listening on TCP port 24/7</td>
<td colspan=2>
Images that target a single application or workflow (often with very complicated stacks), software that has difficult dependencies (e.g. old or different library versions)
</td>
<td>
</td>
<tr>
<td>Examplifying Use Scenario</td>
<td>
A trio of container to host a blogging site: <BR />
One docker container running httpd listen to a mapped TCP port 80 <BR />
A second container running a MySql DB <BR />
Finally a WordPress container running on top taking user requests <BR />
</td>
<td>
<UL>
<LI> A large-ish container with all dependencies build-in, but targetting only a very specific application (eg a custom python program needed a specific version of Anaconda and set of python libraries) <BR />
<LI> A "gigantic" image containing the whole OS of a dying computer, running a mission critical legacy app <BR />
<LI> Potentially docker-like, with many small containers, and string them together via command chain (not sure if there are ways to configure dependencies/versions in definition file) <BR />
</UL>
</td>
<td>
A validated image containing high energy particle physics workflow.
</td>
<td></td>
</tr>
<tr>
<td>Portability</td>
<td>Docker Hub<BR></td>
<td>Single image file. Container purpose build for singularity. Can import docker images. Working to accept docker file or Rocket definition syntax as Singularity definition. <BR />
Singularity Hub host a repository of images and definition files<BR />
</td>
<td>Image Gateway pulls from Docker Hub, automatically convert to shifter image. </td>
<td></td>
</tr>
<!--
<tr>
<td>Potential Cons/Questions?</td>
<td>Not easily adoptable in HPC environment</td>
<td>All dependencies in a single image file -> Requires large storage space? Docker allowed small update if lower stack images remained the same</td>
<td>While live docker images are editable, it requires root. Shifter sanitazed the root requirements, so its containers are immutable? </td>
<td>User need elevated priviledges to start containers ? </td>
</tr>
-->
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Version</td>
<td>1.15-1</td>
<td>2.2 <BR />
Documentation is decent, with many community articles popping up as well.
</td>
<td>16.08.3 (pre-release) <BR />
Documentation is work needing progress :).
</td>
<td>8</td>
</tr>
<tr>
<td>Host OS Req</td>
<td>
Linux kernel 3.10+, eg: <BR />
RHEL 7 <br />
Debian 8.0 <BR />
Ubuntu 12.04<br />
SUSE Linux Enterprise 12<br />
<A HREF="https://docs.docker.com/engine/installation/linux/">other</A>
</td>
<td>
RHEL 6<BR />
Ubuntu <br />
...<BR />
</td>
<td>
Cray Linux Environment<BR />
Linux with kernel 2.6.25+, eg <BR />
RHEL 6. <BR />
...<BR />
</td>
<td>
RHEL 7<BR />
Newer version of Linux that supports Docker/cgroup.
</td>
</tr>
<tr>
<td>Run different OS</td>
<td>Yes. <BR />
docker pull centos/ubuntu/etc
</td>
<td>Yes. Utilize commands like debootstrap and febootstrap to bootstrap a new image</td>
<td>Yes</td>
<td></td>
</tr>
<tr>
<td>Guiding principle</td>
<td></td>
<td>Make container as transparent as possible to user. Run as much as possible as normal user process, change environment only enough to provide portability of the application
</td>
<td>Leverage Docker as it is well established. Extract Docker image into squash-FS, run in chroot env</td>
<td></td>
</tr>
<tr>
<td>Scheduler</td>
<td><A HREF="https://docs.docker.com/swarm/overview/">Docker Swarm</A></td>
<td>Agnostic, run singularity as a job. Works well with Slurm, UGE, etc.</td>
<td>Can work as stand alone container environment. For scalability, scheduler integration currently exist for SLURM, via SPANK plugin. (Should work with other scheduler) </td>
<td><TT>qsub -l</TT> to request docker boolean resource. UGE will be able to assign different priorities to diff containers</td>
</tr>
<tr>
<td>Resource Orchaestration</td>
<td>SwarmKit provided by Docker</td>
<td>Scheduler's job to spin multiple instances on multiple nodes</td>
<td>Yes. <BR/>
<TT>
salloc -N4 ... <BR />srun ...
<TT>
</td>
<td></td>
<!--
<td>Rkt can use Kubernates, Nomad, SwarmKit</td>
-->
</tr>
<tr>
<td>Namespace isolation paradigm</td>
<td>By Default, share little. <BR>
Process, Network, user space are isolated by default, but can be shared via cli arg <BR>
PID 1 is not init, but the process started by docker. <BR>
User inside container cannot see hosts' processes. <BR>
Network typically NAT'ed <BR>
</td>
<td>HPC workflow doesn't benefit much from process isolation, thus by default share most everything, so process running inside container is largely the same as running on actual host. But process namespace isolation can easily be enabled.<BR>
Default share Process Namespace, username space (user inside container can kill process on host) <BR>
While inside a singularity shell, ps -ef shows all process of host, or those of other containers. container user can kill PID of process on host. <BR>
User does not change ID inside container, cannot become root from inside the process. <BR>
Network is transparent to the process. <BR>
/home mount is made available in container, -B will add additional bind mounts easily. <BR>
</td>
<td>Supported</td>
<td></td>
</tr>
<tr>
<td>Resource restriction via cgroup?</td>
<td>docker run -c ... -m ... --cpuset ... </td>
<td>Not touched by Singularity. Scheduler/Resource Manager to control what is available to Singularity </td>
<td>Let SLURM manage cgroup restrictions</td>
<td> <A HREF="https://tin6150.github.io/psg/lsf.html#cgroups">cgroups_params</A> in qconf -mconf
</td>
</tr>
<tr>
<td>MPI</td>
<td>
MP-what? :-)<BR />
</td>
<td>
Singularity has build-in support for MPI (OpenMPI, MPICH, IntelMPI). <BR />
Once app is build with MPI libraries, execute mpirun as normal, replacing the usual binary with the single file singularity app. <BR />
While the app is running inside the singularity container, Process Management Interface (PMI/PMIx) calls will pass thru the singularity launcher onto ORTED. This is what MPI is designed to do, no hacks, so works well.<BR />
</td>
<td>Shifter relies on MPICH Application Binary Interface (ABI). <BR />
Apps that use vanilla MPI that is compatibile with MPICH would work. Site-specific MPI libraries need to be copied to the container at run time. LD_LIBRARY_PATH need to include for example /opt/udiImage/...
</td>
<td></td>
</tr>
<tr>
<td>MPI eg</td>
<td> </td>
<td>
<TT>mpirun singularity exec centos_ompi.img /usr/bin/mpi_ring</TT> <BR/>
<UL>
<LI> The mpirun command is executed on the host. <BR />
<LI> The mpi_ring command is from inside the container. <BR />
<LI> PMIx in OpenMPI perform a version handshake, and everything will work so long as the host's version is equal or newer than the one inside the container. <BR />
<LI> MPI host list come from the host, the container don't need to worry about host discovery. <BR />
<LI> See the <A HREF="#singularity_mpi">singularity mpi diagram</A> below for MPI call flow details.
</UL>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td>IB</td>
<td>Likely ok for IPoIB. Probably no support for RDS.</td>
<td>Native access</td>
<td></td>
<td></td>
</tr>
<tr>
<td>GPU</td>
<td>Your app should run head-less, why you trying to access video card? :-)</td>
<td>Native access, native speed. See
<A HREF="https://hpc.nih.gov/apps/singularity.html#gpu">NIH</A>'s page for setup
</td>
<td>In progress. Reportedly getting near native performance</td>
<td></td>
</tr>
<tr>
<td>Network access</td>
<td>Utilize Network Namespace. NAT is default</td>
<td>Transparent. Access network like any user process would.</td>
<td>Transparent?</td>
<td></td>
</tr>
<tr>
<td>Host's device access</td>
<td></td>
<td>/dev, /sys and /proc are bind mounted to container by default.</td>
<td>/dev, /sys and /proc of host show up inside container</td>
<td></td>
</tr>
<tr>
<td>Host's file system access</td>
<td>
<TT>docker run -v hostpath:containerpath</TT> will bind mount to make host's FS accessible to container. container can be modified and saved. root access possible.
</td>
</td>
<td>
Singularity app run as a user process, therefore it has access to all of host's fs and devices that any user process have access to, including specially optimized FS like Lustre and GPFS. Singularity performs a bind mount between host's mount to the inside of the container. <BR />
<TT>-B /opt:/mnt</TT> will bind mount host's /opt to container's /mnt <BR />
Container writable if started with <TT>-w</TT>. <BR />
Root access possible if singularity is run by root <BR />
</td>
<td>Start shifter with volume mapping, done using loop dev. <BR />
User has access to all typical mounts from host. <BR />
Allows mounting a localized loop mounted file system on each node to act as a local cache, especially useful in diskless cluster. <BR />
<!-- from Lisa G comment -->
</td>
<td>qsub -xdv to map host's FS to container</td>
</tr>
<tr>
<td>Data persistence in image</td>
<TD>
<UL>
<LI>Container is writable at run time, but need to issue <TT>docker commit</TT> from outside the container for changes to persist.
<LI>No host FS mounted/mapped by default. <BR />
</UL>
</TD>
<td>
<UL>
<LI>By default container's FS is mounted Read-only; the bind mounts to the host drive is always writable<BR />
<LI>Can use <TT>-w</TT> flag of singularity to start container in read/write mode.
</UL>
</td>
<td>?</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Deployment</td>
<td>
Single package install. <BR />
Daemon service with root priviledge <BR />
Use in batch processing environment left as an exercise to the reader <BR />
</td>
<td>
root to install singularity, sexec-setuid need setuid root to work correctly. <BR />
Single .rpm/.deb per host.<BR>
No scheduler modification needed.
</td>
<td>
Shifter need to be installed in all hpc nodes <BR />
Docker NOT needed in hpc <BR />
Need an ImageGateway <BR />
</td>
<td>
Upgrade to new version of UGE <BR>
Head and compute nodes need to be newer version of Linux that supports Docker (eg RHEL 7).
</td>
</tr>
<tr>
<td>Container activation</td>
<td>Docker daemon running on each host</td>
<td>loopback mount on singularity image file to utilize container. No daemon process.</td>
<td>No docker daemon on CN. srun ... loopback mount </td>
<td>May employ a set of nodes with running docker daemon, such nodes are flagged as providing a boolean resource for job to make request against. (?)</td>
</tr>
<tr>
<td>Container build-up</td>
<td>
<OL>
<LI>Docker spec file.
<LI>Interactive build container, then use <TT>docker commit</TT>.
<LI>Pull existing image from repository such as docker hub, docker store, private repository.
</OL>
</td>
<td>
<OL>
<LI>Create singularity .def file. Package dependencies are automatically analyzed and incorporated into the image
<LI>Interactive expand on existing image by leveraging <TT>(sudo) singularity shell -w</TT>.
<LI>Import/convert a docker image into a singularity image <TT>singularity import</TT>.
<LI>Share pre-build singularity image file (single sparse file, very compressible). Singularity Hub (coming soon? already exist?)
</OL>
</td>
<td>
<OL>
<LI>Import/convert docker container into shifter container
<LI>Abilities to run image in other format (eg ext4), but not sure how such container image is provisioned.
</OL>
</td>
<td></td>
</tr>
<tr>
<td>Security</td>
<td>
User running docker commands need to be in special docker group to gain elevated system access <BR>
</td>
<td>
No change in security paradigm.<BR>
User run singularity image/app without special privileges. <BR />
Option to start only root-owned container image. <BR />
</td>
<td>
root to install shifter binary. <BR>
Need special integration into scheduler (or only in cray cuz they are special?).<BR>
User run shifter image/app without special privileges. <BR>
</td>
<td></td>
</tr>
<tr>
<td> Root escalation</td>
<td> container starts with priviledged access
</td>
<td>
To obtain root in singularity container, it must have been started as root <BR />
ie, root can be had via <TT>sudo singularity shell centos7.img</TT> <BR />
Container started as normal user cannot use su or sudo to become root; singularity utilize kernel's NO_NEW_PRIV flag (Kernel 3.5 and above). <BR />
ie, <TT>/bin/su</TT> (and <TT>/bin/sudo</TT>), will have setuid flag, but it is blocked from the inside by singularity<BR />
</td>
<td> ?
</td>
<td>
</td>
</tr>
<tr>
<td>Env</td>
<td>
</td>
<td>
<UL>
<LI> container inherit the env of user invoking the singularity cmd<BR />
<LI> /home, /var/tmp, /tmp, /root are bind mount from host and fully writable <BR />
<LI> / is read-only mount and container is typically inmutable (unless started with -w flag)<BR />
</UL>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td>User management</td>
<td>?</td>
<td>Yes. Container has sanitized passwd, group files</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Sample User Commands</td>
<td><TT>
sudo docker pull httpd:latest <BR>
docker images -a <BR>
sudo docker run -p 8000:80 httpd <BR>
</TT></td>
<td><TT>
sudo singularity create ubuntu.img <BR />
sudo singularity bootstrap ubuntu.img ubuntu.def <BR />
singularity exec ubuntu.img bash <BR />
./ubuntu.img </TT> # the %runscript section of the container will autoamtically be invoked <BR />
</td>
<td>
<TT>
module load shifter <BR />
shiftering pull docker:python:3.5 # pull docker image <BR />
shifterimg images # list images <BR />
shifter --image=python:3.5 python # execute a container app <BR />
module load slurm <BR />
sbatch --image=docker:python:3.5 shifter python # run as job <BR />
</TT>
<!--shiftering pull docker:ubuntu:14.04 <BR /> -->
<!-- # pull docker image, recommend specific version rather than using :latest -->
<!--shifter - -image=r-base:latest R # execute a container app <BR />-->
<!--
salloc -n1 - -image=docker:python:3.5.1
srun shifter ./myscript.py #
-->
</td>
<td></td>
</tr>
<tr>
<td>Unix pipes</td>
<td>
output of container captured by pipe. eg: <BR />
<TT>docker run centos:6 ls /etc | wc</TT> <BR />
However, docker won't take standard input, at least not for 1.5-1. The follwing does not work as one might expect: <BR />
<TT>echo 'cat("Hello world\n")' | docker run r-base:latest R --no-save</TT> <BR />
<!-- echo "print hello world" | docker run python:latest python <BR /> -->
</td>
<td>
can daisy chain singularity apps like regular unix commands. eg <BR />
<TT>echo "echo hello world" | singularity exec centos7.img bash </TT> <BR />
</td>
<td>
Shifter will capture standard input as well inside an sbatch script: <BR />
<TT>echo 'cat("Hello world\n")' | shifter R --no-save</TT>
</td>
<td></td>
</tr>
<tr>
<td>Performance</td>
<td>Docker container startup time is much faster than traditional VM, as it does not need to emaulate hardware and is essentially just starting a new process. </td>
<td>
Container startup time a bit faster than docker, as it does away with much of the namespace settings. <BR />
On Lustre backed system, where metadata lookup span different server than data block lookup, single file container image significantly improve performance by reducing multitude of meta data lookup with the MDS.
</td>
<td>
On Lustre backed system, where metadata lookup span different server than data block lookup, single file container image significantly improve performance by reducing multitude of meta data lookup with the MDS.
</td>
<td></td>
</tr>
<tr>
<td>Misc</td>
<td></td>
<td>
Singularity app can run outside HPC, without any job scheduler. It can serve as a container for app portability outside the HPC world, and since a single file encompass the whole container, this maybe advantageous for sharing, portability and archive. <BR />
Singularity recommends compiling all apps into the Singularity container, spec files would need to be written. I hear they are looking to adopt Docker and/or RKT specfile to minimize this burden. <BR />
Docker files can be imported or even run directly. Given docker operate on a different paradigm, the hit-and-miss outcome of such conversion is understandable. <BR />
In future development, maybe NeRSC's shifter could run singularity app as well. <BR />
</td>
<td>
Shifter container/app can run as stand alone outside HPC scheduler. This is certainly useful for testing and development. However, if one isn't trying to utilize container in HPC, maybe there is not much point in converting docker images to shifter images. <BR />
Shifter works by pulling the large number of existing containers. Docker isn't needed inside the HPC, some gateway location can be used for Shifter to pull docker images and store converted image in a location accessible cluster-wide, eg /scratch. See <A HREF="https://tin6150.github.io/psg/blogger_container_hpc.html#shifter_workflow">shifter workflow</A> below for more details. <BR />
</td>
<td></td>
</tr>
<tr>
<td>Feel</td>
<td>High :)</td>
<td>Building a singularity 2.2 image feels a lot like building a VM using kickstart file.
</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Adopters</td>
<td>Like wildfire by internet companies</td>
<td>UC Berkeley, Stanford, TACC, SDSC, GSI, HPC-UGent, Perdue, UFL, NIH, etc. <BR />
Seems like the non-cray community is gravitating toward Singularity. <BR />
</td>
<td>NeRSC, VLSCI, CSCS, CERN, etc. <BR />
Seems like the big physics number crunchers are gravitating toward shifter, cuz they use Cray or IBM Blue Gene? </td>
<td></td>
</tr>
<tr>
<td>Product integration and support</td>
<td><A HREF="https://www.nextflow.io/blog/2014/using-docker-in-hpc-cluster.html">nextflow</A></td>
<td>
<A HREF="https://qlustar.com/news/singularities-docked-sandboxes-and-more">Qluster</A>,
<A HREF="https://www.nextflow.io/blog/2016/more-fun-containers-hpc.html">nextflow</A>, Bright Cluster Manager, Ontropos, Open Cloud/Intel Cluster Orchestrator (in discussion).
</td>
<td>Cray</td>
<td></td>
</tr>
<!--
<tr>
<td>Topic</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
-->
</tbody>
</table>
<!-- ################################################################## -->
<!-- end of table section -->
<!-- ################################################################## -->
<A NAME="workflow"></A>
<BR><BR>
<A NAME="shifter_workflow"></A>
<H3> Shifter Workflow</H3>
As per <A HREF="http://www.slideshare.net/insideHPC/shifter-containers-in-hpc-environments">CSCS/ETH slide share</A>, based on Shifter 15.12.0.
<br/><br/>
<IMG SRC="https://tin6150.github.io/psg/fig/shifter_flow1.png" width="100%"></IMG><BR />
<IMG SRC="https://tin6150.github.io/psg/fig/shifter_flow2.png" width="100%"></IMG><BR />
<IMG SRC="https://tin6150.github.io/psg/fig/shifter_flow3.png" width="100%"></IMG><BR />
<BR><BR>
<A NAME="singularity_workflow"></A>
<H3> Singularity Workflow</H3>
As per <A HREF="http://www.hpcadvisorycouncil.com/events/2017/stanford-workshop/pdf/GMKurtzer_Singularity_Keynote_Tuesday_02072017.pdf">Greg Kurtzer keynote at HPC Advisory Council 2017 @ Stanford</A>, based on Singularity 2.2.
<br/><br/>
<A HREF="http://www.hpcadvisorycouncil.com/events/2017/stanford-workshop/pdf/GMKurtzer_Singularity_Keynote_Tuesday_02072017.pdf#29">
<IMG SRC="https://tin6150.github.io/psg/fig/singularity_flow.png" alt="singularity workflow diagram from GMK keynote"></IMG></A><BR />
<H3> Workflow with Singularity Hub</H3>
<A HREF="http://www.hpcadvisorycouncil.com/events/2017/stanford-workshop/pdf/GMKurtzer_Singularity_Keynote_Tuesday_02072017.pdf#56">
<IMG SRC="https://tin6150.github.io/psg/fig/singularity_hub_flow.png"></IMG></A><BR />
<A NAME="singularity_mpi"></A>
<A NAME="mpi_in_singularity"></A>
<H3>MPI in Singularity</H3>
<A HREF="https://github.com/gmkurtzer/singularityware.github.io/blob/master/images/docs/overview/singularity_mpi.png">
<IMG SRC="https://tin6150.github.io/psg/fig/singularity_mpi.png" alt="singularity mpi diagram"></IMG></A><BR />
<!-- ################################################################## -->
<!-- start of cmd section -->
<!-- ################################################################## -->
<A NAME="docker_cmd"></A>
<A NAME="example_commands_in_docker"></A>
<H3>Example Commands in Docker</H3>
<PRE>
# get a container with anaconda python and jupyter notebook
docker run -i -t -p 8888:8888 continuumio/anaconda /bin/bash -c "/opt/conda/bin/conda install jupyter -y --quiet && mkdir /opt/notebooks && /opt/conda/bin/jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser"
</PRE>
<A NAME="singularity_cmd"></A>
<A NAME="example_commands_in_singularity"></A>
<H3>Example Commands in Singularity</H3>
<PRE>
sudo singularity create --size 2048 /opt/singularity_repo/ubuntu16.img
# Create an image file to host the content of the container.
# Think of it like creating the virtual hard drive for a VM.
# The image created should be a sparse file (ie with holes),
# However, while ext4/ubuntu seems to result in compact file
# RHEL6/ext3 img take up their final file size.
sudo -E singularity bootstrap /opt/singularity_repo/ubuntu16.img /opt/src/singularity/examples/ubuntu.def
# "kickstart" build the container
# If behind a proxy, sudo -E will preserve http_proxy env var
singularity shell ubuntu.def
singularity exec ubuntu.img bash # slight diff than shell, PS1 not changed, .bash_profile sourced here
singularity exec centos.img rpm -qa
# Note that uname and uptime will always report info of the host, not the container.
singularity exec -w centos.img zsh # -w for writable container, FS ACL still applies
# centos.img needs to be writable by the user
sudo singularity shell -w centos.img # root can edit all contents inside container
# best to build up container using kickstart mentality.
# ie, to add more packages to image, vi /opt/src/singularity/exampless/ubuntu.def
# re-run bootstrap command again.
# bootstap on existing image will build on top of it, not overwritting it/restarting from scratch
# singularity .def file is kinda like kickstart file
# unix commands can be run, but if there is any error, the bootstrap process ends.
# pipe and redirect works as input and output for singularity container executions:
echo "echo hello world" | singularity exec centos7.img bash
singularity exec centos7.img echo 'echo hello world' | singularity exec centos7.img bash
singularity exec centos7.img rpm -qa | singularity exec centos7.img wc -l
singularity exec centos7.img python < ./myscript.py
</PRE>
<H3>Example Singularity container definition file</H3>
CentOS:
<PRE class="code">
# Copyright (c) 2015-2016, Gregory M. Kurtzer. All rights reserved.
#
# "Singularity" Copyright (c) 2016, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory (subject to receipt of any
# required approvals from the U.S. Dept. of Energy). All rights reserved.
BootStrap: yum
OSVersion: 7
MirrorURL: http://mirror.centos.org/centos-%{OSVERSION}/%{OSVERSION}/os/$basearch/
Include: yum
# If you want the updates (available at the bootstrap date) to be installed
# inside the container during the bootstrap instead of the General Availability
# point release (7.x) then uncomment the following line
#UpdateURL: http://mirror.centos.org/centos-%{OSVERSION}/%{OSVERSION}/updates/$basearch/
%runscript
echo "This is what happens when you run the container..."
%post
echo "Hello from inside the container"
yum -y install vim-minimal
# adding a number of rather useful packages
yum -y install bash
yum -y install zsh
yum -y install environment-modules
yum -y install which
yum -y install less
yum -y install sudo # binary has setuid flag, but it is not honored inside singularity
yum -y install wget
yum -y install coreutils # provide yes
yum -y install bzip2 # anaconda extract
yum -y install tar # anaconda extract
# bootstrap will terminate on first error, so be careful!
test -d /etc/singularity || mkdir /etc/singularity
touch /etc/singularity/singularity_bootstart.log
echo '*** env ***' >> /etc/singularity/singularity_bootstart.log
env >> /etc/singularity/singularity_bootstart.log
# install anaconda python by download and execution of installer script
# the test condition is so that subsequent singularity bootstrap to expand the image don't re-install anaconda
cd /opt
[[ -f Anaconda3-4.2.0-Linux-x86_64.sh ]] || wget https://repo.continuum.io/archive/ Anaconda3-4.2.0-Linux-x86_64.sh
[[ -d /opt/anaconda3 ]] || bash Anaconda3-4.2.0-Linux-x86_64.sh -p /opt/anaconda3 -b # -b = batch mode, accept license w/o user input
</PRE>
Ubuntu snipplet. <BR />
I found that --force-yes is needed <BR />
debootstrap rpm is needed in a CentOS machine for this bootstrap to work <BR />
<PRE class="code">