鍐呭棰勮
- 浠€涔堟槸杞欢瀹瑰櫒锛堟湁浠€涔堝ソ澶勶紵锛?/li>
- 浠€涔堟槸Singularity?
- 鏋勫缓Singularity瀹瑰櫒
- 瀹瑰櫒鏋勫缓娴佺▼鍥?/li>
浠€涔堟槸杞欢瀹瑰櫒锛堟湁浠€涔堝ソ澶勶紵锛?/h3>
鍏充簬瀹瑰櫒鎶€鏈紝鍦ㄤ互寰€鐨勬枃绔犱腑宸蹭粙缁嶈繃涓€娆°€?br> 鏈枃閲嶇偣浠嬬粛Singularity鐨勫繀闇€鎶€鏈紝浠ュ強濡備綍鏋勫缓涓€涓睘浜庤嚜宸辩殑瀹瑰櫒锛屽湪鍏ㄦ枃鏈€鍚庯紝闄勪笂涓€寮犳瀯寤哄鍣ㄧ殑娴佺▼鍥句緵澶у鍙傝€冦€?/p>
棣栧厛浠ュ疄闄呭簲鐢ㄤ緥瀛愭潵璇达紝鍊熷姪浜庡鍣ㄦ妧鏈垜浠彲浠ュ疄鐜板摢浜涙搷浣滐紵
鎵撳寘鍒嗘瀽绠¢亾锛屼娇鍏跺湪鎮ㄧ殑绗旇鏈數鑴戙€佷簯绔拰楂樻€ц兘璁$畻 (HPC) 鐜涓繍琛岋紝浠ヤ骇鐢熺浉鍚岀殑缁撴灉銆?/p>
鍙戣〃璁烘枃骞跺寘鍚寚鍚戝寘鍚偍浣跨敤鐨勬墍鏈夋暟鎹拰杞欢鐨勫鍣ㄧ殑閾炬帴锛屼互渚垮叾浠栦汉鍙互杞绘澗閲嶇幇鎮ㄧ殑缁撴灉銆?/p>
閫氳繃鍑犳鍑婚敭鍗冲彲瀹夎骞惰繍琛岄渶瑕佸鏉備緷璧栧叧绯诲爢鏍堢殑搴旂敤绋嬪簭銆?/p>
鍒涘缓绠¢亾鎴栧鏉傜殑宸ヤ綔娴佺▼锛屽叾涓瘡涓崟鐙殑绋嬪簭閮藉簲鍦ㄤ笉鍚岀殑鎿嶄綔绯荤粺涓婅繍琛屻€?/p>
馃憠
鎯冲繀寰堝鍚屽閬囧埌杩囪繖鏍风殑鍦烘櫙鍦ㄦ湰鍦扮數鑴戜笂璋冭瘯濂界殑鍒嗘瀽杞欢锛屽嵆浣挎槸鍚屾牱鐨勫畨瑁呮墜鍐岋紝鍦ㄥ疄楠屽/瓒呯畻涓績鐨勭數鑴戜笂锛屾娲昏涓嶄笂锛岄亣鍒板悇绉嶅鎬殑鎶ラ敊锛屼緥濡俶ake澶辫触銆乧pp棰勫鐞嗗櫒鐗堟湰涓嶆敮鎸併€佸畨瑁卲erl杞欢鐨刢pan鍖呬緷璧栧畨瑁呭け璐ョ瓑绛夈€?/p>
鍥犳锛屽浜庡垰寮€濮嬫帴瑙︿俊鎭垎鏋愮殑灏忎紮浼存潵璇达紝鎺屾彙杩欓棬鎶€鏈紝瀵逛簬瀹炵幇鍒嗘瀽绋冲畾澶嶇幇銆佸湪楂樻€ц兘鏈嶅姟鍣ㄤ笂蹇€熼厤缃垎鏋愮閬撶瓑閮芥湁闈炲父閲嶈鐨勪綔鐢?/p>
浠€涔堟槸Singularity锛?/h2>
Singularity涓嶥ocker涓€鏍凤紝閮芥槸瀹瑰櫒鎶€鏈殑涓€绉嶃€?/p>
灏界锛孲ingularity纭疄瀛樺湪涓€浜涗笉鍙拷瑙嗙殑寮辩偣锛屼緥濡傛瘮Docker鏇翠笉鎴愮啛浠ュ強鏇村皬鐨勭ぞ鍖虹敤鎴枫€?/p>
鍏剁湡姝g殑浼樺娍鍦ㄤ簬楂樻€ц兘鏈嶅姟鍣ㄤ笂閮ㄧ讲鍒嗘瀽绠¢亾鏃讹紝鏃犻渶root鏉冮檺銆佸畨鍏ㄦ€т互鍙婁綆鎴愭湰鐨勫叆闂ㄥ涔狅紝骞朵笖鑳芥棤缂濆湴灏咲ocker瀹瑰櫒杞崲涓簊ingularity瀹瑰櫒銆?/p>
鑰孌ocker鏃犺鏄鍣ㄦ瀯寤恒€佽繍琛屻€佺敓鎴愮殑缁撴灉鏂囦欢锛岄兘闇€瑕乺oot鏉冮檺锛岃繖瀵逛簬鐢ㄦ埛浣跨敤鏉ヨ闈炲父涓嶆柟渚裤€?/p>
Singularity鐨勫揩閫熷畨瑁?/h2>
棣栧厛锛屾垜浠渶瑕佺‘淇濅竴浜涘繀闇€鐨勫寘宸茬粡寰楀埌瀹夎
鍦║buntu涓紙鏍规嵁linux绯荤粺閫夋嫨锛?/p>
$ 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
鍦–entos涓紙鏍规嵁linux绯荤粺閫夋嫨锛?/p>
$ 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
鎺ョ潃锛宻ingularity浣跨敤Golang缂栧啓锛屽洜姝ら渶瑕佸畨瑁匞o璇█
$ wget https://dl.google.com/go/go1.13.linux-amd64.tar.gz
$ sudo tar --directory=/usr/local -xzvf go1.13.linux-amd64.tar.gz
# 姝ゅ灏咷o娣诲姞鍒颁复鏃剁幆澧冧腑锛屽鏋滈渶瑕佸紑鏈鸿嚜鍚紝璇蜂慨鏀箏/.bashrc鏂囦欢
$ export PATH=/usr/local/go/bin:$PATH
# 瑙e帇
$ 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
涔嬪悗锛屾瀯寤哄畨瑁卻ingularity
$ cd singularity
$ ./mconfig
$ cd builddir
$ make
$ sudo make install
濡傛灉甯屾湜singularity鏀寔tab琛ュ叏
$ . etc/bash_completion.d/singularity
$ sudo cp etc/bash_completion.d/singularity /etc/bash_completion.d/
鏈€鍚庯紝娴嬭瘯瀹夎
$ singularity run library://godlovedc/funny/lolcow
# 濡傛灉瀹夎姝e父锛屽垯浼氬嚭鐜颁互涓嬪唴瀹癸細
INFO: Downloading library image
_______________________________________
/ Excellent day for putting Slinkies on \
\ an escalator. /
---------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
Singularity瀹瑰櫒涓嬭浇
鍦ㄧ嚎鐨勫鍣ㄥ簱锛?/p>
The Singularity Container Library, 鐢?Sylabs 寮€鍙戝拰缁存姢
Docker Hub, 鐢?Docker 寮€鍙戝拰缁存姢
Quay.io, 鐢辩孩甯藉紑鍙戝拰缁存姢
NGC, 鐢?NVIDIA 寮€鍙戝拰缁存姢
BioContainers, 鐢?Bioconda 闆嗗洟寮€鍙戝拰缁存姢
Amazon AWS銆丮icrosoft Azure 鍜?Google Cloud 绛変簯鎻愪緵鍟嗕篃鎷ユ湁鍙笌 Singularity 閰嶅悎浣跨敤鐨勫鍣ㄦ敞鍐岃〃
绫讳技浜巇ocker锛宻ingularity涔熻兘浠庣綉缁滀笂浣跨敤pull鍛戒护鏉ヤ笅杞藉鍣?/p>
# 浠巗ingularity搴撲笅杞藉鍣?
$ singularity pull library://godlovedc/funny/lolcow
# 涓嬭浇瀹屾垚鍚庯紝灏嗕細鐪嬭涓€涓猻if缁撳熬鐨勬枃浠讹紝杩欎釜灏辨槸singularity鐨勫鍣ㄦ枃浠?
lolcow_latest.sif
# 涔熷彲浠ヤ粠docker搴撲笅杞藉鍣?
$ singularity pull docker://godlovedc/lolcow
Singularity瀹瑰櫒浣跨敤
杩涘叆瀹瑰櫒锛?code>shell鍛戒护
$ singularity shell lolcow_latest.sif
閫€鍑哄鍣細exit
鍛戒护
# 鍦ㄥ鍣ㄧ幆澧冧腑
Singularity> exit
# 灏变細杩斿洖鍒扮湡瀹炵幆澧冧笅
~>
鍦ㄥ鍣ㄥ唴鎵ц浠诲姟锛?code>exec鍛戒护
$ singularity exec lolcow_latest.sif cowsay 'How did you get out of the container?'
_______________________________________
< How did you get out of the container>
---------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
杩愯瀹瑰櫒锛?code>run鍛戒护
$ singularity run lolcow_latest.sif
# 姝ゅ鐨剅un锛屽疄闄呬笂鏄皟鐢ㄥ鍣ㄥ唴鐨勪竴涓猺unscript鐨勭壒娈婃枃浠?
# 妫€鏌ュ鍣ㄥ唴鐨剅unscript鏂囦欢
$ singularity inspect --runscript lolcow_latest.sif
#!/bin/sh
fortune | cowsay | lolcat
# 姝ゅ锛屼篃鍙互鍍忚繍琛岃蒋浠朵竴鏍锋潵浣跨敤瀹瑰櫒锛屼緥濡?
./lolcow_latest.sif
鏋勫缓Singularity瀹瑰櫒
瑕佹瀯寤轰竴涓鍣紝蹇呴』浣跨敤build
鍛戒护
涓€涓爣鍑嗙殑瀹瑰櫒寮€鍙戝懆鏈熶负锛?/p>
缂栧啓涓€涓彲鍐欑殑瀹瑰櫒锛坰andbox锛?/p>
浣跨敤--writeable杩涘叆瀹瑰櫒锛屼互浜や簰鏂瑰紡瀵瑰鍣ㄨ繘琛屼慨鏀?/p>
瀵规枃浠惰繘琛屼慨鏀?/p>
閲嶆柊build
閲嶅鍓嶄袱姝ワ紝鐩村埌瀹瑰櫒鍙樻垚鎴戜滑鏈熸湜鐨勭姸鎬?/p>
build骞朵繚瀛樺鍣紝浠ヤ緵鐢熶骇浣跨敤
渚嬪鎴戜滑鎵嬪ご宸茬粡鏈変竴涓幇鎴愮殑recipes锛堢敤浜巄uild鐨勫懡浠ゆ枃浠讹級
BootStrap: debootstrap
OSVersion: stable
MirrorURL: http://ftp.us.debian.org/debian/
%runscript
echo "This is what happens when you run the container..."
%post
echo "Hello from inside the container"
apt-get -y --allow-unauthenticated install vim
鍦ㄨ繖涓枃浠朵腑锛?寮€澶寸殑閫氬父琛ㄧず鍦ㄦ瀯寤鸿繃绋嬩腑璧风潃涓€瀹氱壒娈婁綔鐢紝鍏蜂綋鍙互鍙傝€冩枃妗o細https://docs.sylabs.io/guides/3.5/user-guide/definition_files.html
甯哥敤鐨勭鍙锋湁锛?/p>
%post(鎵ц鍛戒护锛屽涓嬭浇銆佸畨瑁呫€佺紪鍐欓厤缃枃浠躲€佸垱寤虹洰褰曠瓑)
%files(灏嗘枃浠跺鍒跺埌瀹瑰櫒涓?
%test(鏋勫缓瀹屾垚鍚庯紝娴嬭瘯瀹瑰櫒)
%environment(璁剧疆鐜鍙橀噺锛岀被浼间簬淇敼.bashrc)
%runscript(姣旇緝鐗规畩锛屽湪鍛煎嚭瀹瑰櫒鏃讹紝鍙互鑷姩鎵ц璁″垝鐨勪换鍔?
浠庡ご鏋勫缓涓€涓鍣?/h3>
瀵逛簬鏂版墜鑰岃█锛岄€氬父鍦╞uild瀹瑰櫒鏃讹紝闇€瑕佺粰鍑?-sandbox閫夐」锛岃繖鍦ㄦ垜浠繕涓嶇煡閬撳鍣ㄥ紑鍙戝叿浣撻渶瑕佸寘鍚粈涔堟枃浠剁殑鏃跺€欙紝闈炲父鏈夌敤
寮€濮媌uild瀹瑰櫒
$ sudo singularity build --sandbox lolcow lolcow.def
杩愯瀹屾垚鍚庯紝浼氬湪褰撳墠鐩綍涓嬬湅鍒颁竴涓猯olcow鏂囦欢
瀵瑰鍣ㄨ繘琛屾帰绱㈠拰淇敼
$ sudo singularity shell --writable lolcow
Singularity> apt-get update
Singularity> apt-get install -y fortune cowsay lolcat
姝ゆ椂鍙互鐪嬪埌搴旂敤绋嬪簭鎴愬姛瀹夎锛屼絾濡傛灉娌℃湁浣跨敤--writeable鍙傛暟锛岄偅涔堝湪杩涘叆瀹瑰櫒鍚庯紝鎵ц瀹夎鍛戒护锛岄€氬父浼氳鍛婄煡杩欎簺鏂囦欢閮芥槸read-only锛屼笉鍙慨鏀?/p>
闇€瑕佽鏄庣殑鏄紝涓巇ocker绫讳技锛屽湪瀹瑰櫒涓繘琛岀殑鎿嶄綔锛屽湪閫€鍑哄鍣ㄥ悗锛岃繖浜涗慨鏀瑰苟涓嶄細淇濆瓨锛屽鏋滆浣胯繖浜涗慨鏀规案涔呯敓鏁堬紝灏遍渶瑕佸皢杩欎簺鎿嶄綔鍔犲叆鍒板畾涔夋枃浠朵腑锛岄噸鏂癰uild
浠庣幇鏈夊鍣ㄦ瀯寤?/h3>
浠庣幇鏈夊鍣ㄦ瀯寤猴紝闇€瑕佹敞鎰忕殑鏄紝瑕佷慨鏀筨uild瀹氫箟鏂囦欢鐨刪eader
渚嬪闇€瑕佷互瀹瑰櫒搴撲腑鐜版湁鐨勫鍣ㄤ綔涓鸿捣鐐?/p>
# 渚嬪浠ebian涓鸿捣鐐?
BootStrap: library
From: debian
# 鎴栬€呬粠docker hub涓婄殑debian鍚姩
Bootstrap: docker
From: debian
# 鍐嶆垨鑰呬互鏈湴鏂囦欢绯荤粺涓婄殑鍩虹瀹瑰櫒鍚姩
Bootstrap: localimage
From: /home/test/debian.sif
涓庝粠澶存瀯寤哄鍣ㄧ浉姣旓紝浠庣幇鏈夊鍣ㄦ瀯寤虹殑鏈€澶уソ澶勬槸涓嶉渶瑕乺oot鏉冮檺
$ singularity build debian3.sif debian2.sif
瀹夊叏鐨勬瀯寤哄鍣?/h3>
鍦╯ingularity涓紝鎻愪緵浜?-fakeroot閫夐」锛屽彲浠ヤ互鏇村畨鍏ㄧ殑鏂瑰紡鍦ㄥ鍣ㄤ腑浣跨敤root鏉冮檺鏉uild瀹瑰櫒
$ singularity build --fakeroot container.sif container.def
瀹瑰櫒鎸傝浇涓绘満鏂囦欢
榛樿鎯呭喌涓嬶紝瀹瑰櫒杩愯鍚庝細鑷姩缁戝畾涓绘満鐨勫嚑涓洰褰曪紝鍖呮嫭锛?/p>
$HOME
/tmp
/proc
/sys
/dev
姝ゅ锛屼篃鍙互浣跨敤--bind/-B/SINGULARITY_BINDPATH鏉ユ寚瀹氶渶瑕佺粦瀹氱殑鍏朵粬鐩綍
鑷虫锛屼綘宸茬粡鎺屾彙浜嗘瀯寤轰竴涓猻ingularity瀹瑰櫒鐨勫繀椤绘妧鑳戒簡锛屽彲浠ュ幓灏濊瘯鏋勫缓涓€涓睘浜庤嚜宸辩殑瀹瑰櫒銆?/p>
瀹瑰櫒鏋勫缓娴佺▼鍥?/h3>
鏈枃鐢卞崥瀹竴鏂囧鍙戝钩鍙?OpenWrite 鍙戝竷锛?/p>
鏈枃鐢卞崥瀹竴鏂囧鍙戝钩鍙?OpenWrite 鍙戝竷锛?/p>