Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
コンテナは友だち! in RailsDM /container-ga-tokui-na-fri...
Search
KONDO Uchio
November 16, 2017
Technology
3
2.7k
コンテナは友だち! in RailsDM /container-ga-tokui-na-friends-in-railsdm
Rails Developers Meetup #7
https://techplay.jp/event/631428
KONDO Uchio
November 16, 2017
Tweet
Share
More Decks by KONDO Uchio
See All by KONDO Uchio
大規模レガシーテストを 倒すための CI基盤の作り方 / #CICD2023
udzura
5
2.3k
Ruby x BPF in Action / RubyKaigi 2022
udzura
0
200
Narrative of Ruby & Rust
udzura
0
180
開発者生産性指標の可視化 / pepabo-four-keys
udzura
3
1.6k
Talk of RBS
udzura
0
400
Re: みなさん最近どうですか? / FGN tech meetup in 2021
udzura
0
710
Dockerとやわらかい仮想化 - ProSec-IT/SECKUN 2021 edition -
udzura
2
680
Device access filtering in cgroup v2
udzura
1
780
"Story of Rucy" on RubyKaigi takeout 2021
udzura
0
730
Other Decks in Technology
See All in Technology
オプトインカメラ:UWB測位を応用したオプトイン型のカメラ計測
matthewlujp
0
170
あの日俺達が夢見たサーバレスアーキテクチャ/the-serverless-architecture-we-dreamed-of
tomoki10
0
420
株式会社ログラス − エンジニア向け会社説明資料 / Loglass Comapany Deck for Engineer
loglass2019
3
31k
LINEスキマニにおけるフロントエンド開発
lycorptech_jp
PRO
0
330
OpenShift Virtualizationのネットワーク構成を真剣に考えてみた/OpenShift Virtualization's Network Configuration
tnk4on
0
130
非機能品質を作り込むための実践アーキテクチャ
knih
2
660
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
150
GitHub Copilot のテクニック集/GitHub Copilot Techniques
rayuron
23
11k
KubeCon NA 2024 Recap: How to Move from Ingress to Gateway API with Minimal Hassle
ysakotch
0
200
AWS re:Invent 2024で発表された コードを書く開発者向け機能について
maruto
0
180
Storage Browser for Amazon S3
miu_crescent
1
130
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
180
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Docker and Python
trallard
41
3.1k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
KATA
mclloyd
29
14k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Optimizing for Happiness
mojombo
376
70k
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
GraphQLとの向き合い方2022年版
quramy
44
13k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Transcript
ා͘ͳ͍γεςϜϓϩάϥϛϯάGPS3BJMT%. ۙ౻Ӊஐ࿕(.01FQBCP *OD 3BJMT%FWFMPQFST.FFUVQ ίϯςφ༑ͩͪʂ
ΤϯδχΞ ۙ౻Ӊஐ࿕!VE[VSB ٕज़෦ٕज़ج൫νʔϜ ͖ͳϥʔϝϯΒʔΊΜཾ (.0ϖύϘॴଐ
ུྺ w&$αΠτɺιʔγϟϧήʔϜͷ։ൃͳͲΛܦͯɺ ΑΓ(.0ϖύϘٕज़ج൫νʔϜɺಉԬʹҠॅɻ ͖ͳϥʔϝϯΒʔΊΜཾɺ͖ͳΧϨʔ5JLJɻ wஶॻʹʰύʔϑΣΫτ3VCZPO3BJMTʱ΄͔ɻ w3VCZ,BJHJʹࣗ࡞ίϯςφʮ)BDPOJXBʯͷ͕࠾ɻ w3BJMT(JSMT'VLVPLBΦʔΨφΠβɺԬ3VCZձ࣮ٞߦҕһɻ w΄͔ɺ3VCZίϯςφʹؔ͢Δ׆ಈଟɻ
࠷ۙͷࣄͷએͰ͢ w3VCZPO3BJMT͕͑ΔϗεςΟϯάαʔϏεͷ ΞʔΩςΫτʢࣗশʣΛ͍ͬͯ·͢ɻ wϑϩϯτΤϯυ/VYUKT &YQSFTTɺ443Ͱ͢ w෦"1*(Pͷ&DIPͰ͢ wྶΔͣ wࠓͷॴЋఏڙதɻ͓ͪΛ
Ԭ3VCZձٞ! IUUQSFHJPOBMSVCZLBJHJPSHGVLVPLB ചΓΕ·ͨ͠
ؓ ٳ
ࠓͷΞδΣϯμ w ϓϩηεͱԿͩΖ͏ʁ w ίϯςφͱԿͩΖ͏ʁ w ΈΜͳίϯςφʹͳͬͯΈΑ͏ʁʁʁ
ϓϩηεͱʁ
'SPNް͍ຊ w-*/69ϓϩάϥϛϯάΠϯλʔϑΣʔε ΦϥΠϦʔ ͜ͷதͰҰ൪ް͍ຊ
ϓϩηεͱϓϩάϥϜͷ࣮ߦதͷ࢟Ͱ͢ ʮϓϩηεͱɺϓϩάϥϜͷ࣮ߦʹඞཁ ͳγεςϜϦιʔεΛׂΓͯΔͨΊɺΧʔ ωϧ͕ఆٛ͢ΔநΤϯςΟςΟͰ͋Δʯͱ ݴ͍͑ΒΕ·͢ɻ ʰ-JOVYϓϩάϥϛϯάΠϯλʔϑΣʔεʱষϓϩηε
ϓϩηεͱ৮Ε߹͏ wʮϓϩάϥϜͷ࣮ߦʹඞཁͳϦιʔεʯΛ͍ͯΈΔ wͦΕ͕ɺ͢ͳΘͪϓϩηεଐੑͰ͋Δ wྫ w 1*%ɺ1*% w εςʔλεʢ࣮ߦՄೳɺ*0ͪɺʣ w ڥม
w ϑΝΠϧσΟεΫϦϓλςʔϒϧ w 6TFS*%(SPVQ*% w ݖݶʢ,FSOFM$BQBCJMJUZʣ w ΧϨϯτσΟϨΫτϦ w ϝϞϦϚοϐϯά
TUSVDUUBTL@TUSVDU
QSPDQSPDGT wγεςϜϓϩηεͷใΛऔಘͰ͖ΔಛघϑΝΠϧγεςϜ wQSPDͷԼʹ࠷ॳ͔ΒϚϯτ͞Ε͍ͯΔ߹͕ଟ͍ɻ wϚϯτ͞Ε͍ͯͳ͍ͱ͑ͳ͍πʔϧ͋ΔʢQTɺUPQͦͷଞʣ
தΛݟͯΈΑ͏ wԋश ͘ଘࡏ͢ΔΑ͏ͳϓϩηεΛ࡞ͬͯΈΑ͏ɻ w ͦͷϓϩηεͷ1*%Λಛఆ͠Α͏ɻ w ͦͷϓϩηεʹ͍ͭͯɺҎԼͷใΛऔಘͯ͠ΈΑ͏ɻ
w ΧϨϯτσΟϨΫτϦ IJOUQSPD1*%DXE w ڥม IJOUQSPD1*%FOWJSPO w ϝϞϦϚοϐϯά IJOUQSPD1*%NBQT w εϨουͷ IJOUQSPD1*%UBTL
ղྫ wσϞ͠·͢ w(JTUIUUQCJUMZSENDPOUBJOFST
ίϯςφͱʁ
ԾԽͷछྨʢҰྫʣ wϋΠύʔόΠβܕʢωΠςΟϒϋΠύʔόΠβʣ wઐ༻ͷ04ɺ-JOVY,FSOFMࣗମΛϋΠύʔόΠβͱ͍ͯ͠ɺͦͷ ্Ͱ04ΛΒͤΔ wϗετ04ܕʢϗετϋΠύʔόΠβʣ w൚༻తͳ04ͷ্ʹɺ7JSUVBM#PYͷΑ͏ͳԾԽͷͨΊͷઐ༻ιϑτ ΣΞΛೖΕͯΒͤΔ wίϯςφܕˠ
ίϯςφͱ wখ͞ͳಠཱͨ͠ڥΛɺҰͭͷ04ͷ্ʹ࡞Δٕज़ɻ wͨͩ͠ɺԾԽٕज़ͷΑ͏ʹѻΘΕΔ͕ɺԿ͔ΛԾతʹ࡞͍ͬͯΔ ͱ͍͏͜ͱͰͳ͍
ίϯςφ ಛघͳϓϩηεͰ͋Δ
͜Ε͚֮ͩ͑ͯؼͬͯ͘Εʂʂ̍
ίϯςφͷ࣮ w%PDLFS(PMBOHɻ,VCFSOFUFTͳͲͱ࿈ܞ͠ɺঃʑʹ׆༻γʔϯ ͕·͍ͬͯΔ w-9$-9%ΧʔωϧͷίϯςφϨϑΝϨϯε࣮తཱͪҐஔɻ $ (PMBOH w)BDPOJXBNSVCZ $ݴޠͰͰ͖ͨίϯςφɻ3VCZͷ%4-Ͱίϯ ςφΛఆٛͰ͖Δɻ(.0ϖύϘͱ͍͏ձ͕ࣾϚωʔδυΫϥυͷ όοΫΤϯυʹ࠾༻͠ʹɻ
ίϯςφͲ͏ͬͯ࡞ΒΕ͍ͯΔ͔ wࠓ͋͛ͨ-JOVYίϯςφͷ࣮Ͱɺجຊతʹಉ͡ΧʔωϧͷػೳΛ Έ߹Θͤͯɺʮখ͘͞ಠཱͨ͠ڥʯΛ࡞͍ͬͯΔɻ wͦͷػೳ͕ద༻͞Ε͍ͯΔ͔͍ͳ͍͔ɺϓϩηεͷଐੑͰ͋Δͷ ͰɺQSPDͷԼͳͲ͔Β֬ೝ͢Δ͜ͱ͕Ͱ͖·͢
%PDLFSͰίϯςφΛ࡞ͬͯΈΑ͏
QSPD1*%OTͷԼΛݟͯΈΑ͏
͜Εɺଞͷϓϩηεͱҧ͍ͬͯΔ wͱ͍͏͜ͱΛ֬ೝ͢Δ
͜Εɺଞͷϓϩηεͱҧ͍ͬͯΔ wͱ͍͏͜ͱΛ֬ೝ͢Δ ◀ ◀ ◀ ◀ ◀
-JOVY/BNFTQBDF
-JOVY/BNFTQBDFͱ wΧʔωϧɺάϩʔόϧͰཧ͍ͯ͠ΔϦιʔε͕ͨ͘͞Μ͋Δɻ wͦ͏͍͏Ϧιʔεͷ͏ͪҰ෦ɺ໊લۭؒΛͬͯɺಛఆͷϓϩηε ͨͪͷͨΊʹผͷϦιʔεΛ֬อ͢Δ͜ͱ͕Ͱ͖Δ w654/BNFTQBDFϗετ໊ͳͲ w1*%/BNFTQBDFϓϩηε*% w/FUXPSL/BNFTQBDFωοτϫʔΫઃఆʢ/*$ଞʣ wͳͲͳͲɻ࠷৽ͷ-JOVYͰਓͷࣆͭͷ/BNFTQBDF
QSPD1*%OTͱ wʮͦͷϓϩηε͕ॴଐ͢Δ/BNFTQBDFΛදݱ͢ΔϑΝΠϧʯΛ ݟ͚ͭΔ͜ͱ͕Ͱ͖ΔσΟϨΫτϦ w͋Δϓϩηεͱɺผͷϓϩηε͕ҧ͏ϑΝΠϧʢJOPEF൪߸ʣΛ ͍ࠩͯ͠Εɺͦͷϓϩηεͨͪผʑͷ໊લۭؒʹ͍ΔͶɺ ͱ֬ೝͰ͖Δ
DHSPVQ
QSPD1*%DHSPVQͱ͍͏ϑΝΠϧ wͳʹΒಛघͳจࣈྻ͕ॻ͔Ε͍ͯΔ
࣮ࡍͷσΟϨΫτϦʹରԠ͢Δ wTZTGTDHSPVQͱ͍͏ͱ͜ΖΛௐΔͱ
͜Ε͕DHSPVQ wDHSPVQɺͱͱϓϩηεΛάϧʔϐϯά͢ΔͨΊͷػೳɻ wϓϩηεͷάϧʔϓຖʹɺ$16ͷར༻Ͱ͋ͬͨΓɺϝϞϦͰ͋ͬͨ Γɺ1*%ͷͰ͋ͬͨΓɺͷ੍ݶΛ͔͚Δ͜ͱ͕Ͱ͖Δɻ͋Δ͍ɺ άϧʔϓผͷར༻ঢ়گΛ֬ೝͨ͠ΓͰ͖Δ wDHSPVQʹؔ͢Δૢ࡞ɺDHSPVQGTͱ͍͏ಛघϑΝΠϧγεςϜΛ ܦ༝ͯ͠Ͱ͖Δ
࣮ࡍͷ੍ݶΛ֬ೝ •docker run --pids-limit=128 -ti debian:jessie /bin/bash wͷΑ͏ͳίϚϯυͰɺϓϩηεͷDHSPVQ੍ݶΛ͔͚ΒΕΔ w͜ͷγΣϧͰɺGPSLCPNC߈ܸΛͯ͠ɺؼͬͯ͘Δ
None
ͦͷଞͷػೳ wDISPPU Ͱɺಠཱͨ͠ϑΝΠϧγεςϜπϦʔʹʮೖΓࠐΉʯ wηΩϡϦςΟपΓͷػೳ੍ݶ w,FSOFM$BQBCJMJUZͰSPPUͷػೳΛߜΓࠐΉʢٯવΓʣ wTFDDPNQͰɺγεςϜίʔϧ୯Ґͷݺͼग़͠ΛϑΟϧλʔ w."$ .BOEBUPSZ"DDFTT$POUSPM 4&-JOVY
"QQ"SNPS
ΈΜͳίϯςφʹ ͳͬͯΈΑ͏ʁʁʁ
͜͜·Ͱͷ·ͱΊ wίϯςφͨͩͷ ϓϩηεɻා͘ͳ͍Αʂ
ͱ͍͏͜ͱͰ wίϯςφΛܰʙ͘ϋϯυϝΠυͯ͠Έ·͠ΐ͏͔ɻ
ಠཱͨ͠SPPUʹ͍Δ wEFCPPUTUSBQͱݴ͏ίϚϯυͰɺ%FCJBOͷϑΝΠϧγεςϜ͚ͩΛ ४උͰ͖Δɻ wDISPPU ͱݴ͏ίϚϯυͰɺͦͷதʹೖΔ͜ͱ͕Ͱ͖·͢ w ࣮%PDLFSͳ͠Ͱɺ6CVOUVͷதͰ%FCJBOڥΛಘΔ͜ͱͰ͖Δ mkdir
/root/railsdm-7th debootstrap --variant=minbase \ jessie \ /root/railsdm-7th \ http://ftp.jp.debian.org/debian
None
/BNFTQBDFΛ͢Δ wVOTIBSFͱݴ͏ίϚϯυΛ͏ͱͰ͖Δ •unshare --fork --pid --mount --uts wͷΑ͏ʹͯ͠ɺ1*%/BNFTQBDFɺ.PVOU/BNFTQBDFɺ654 /BNFTQBDFΛͰ͖Δ
ʢGPSL1*%/BNFTQBDFͷ༷ʹΑΔ੍ݶʣ
DHSPVQͷ੍ݶΛ͔͚Δ w৽͍͠DHSPVQɺ NLEJSͳͲͰ؆୯ʹ࡞ΕΔ wࣗΛॴଐͤ͞ΔʹɺUBTLTͱ͍͏ϑΝΠϧʹࣗͷ1*%Λॻ͖ࠐ Ί0,ɻ •echo $$ > /sys/fs/cgroup/cpu/7th-engineer/tasks
Ұ࿈ͷॲཧΛͭͳ͛Δ $ cat after-unshare.rb #!/usr/bin/env ruby container_name = ARGV[0]
raise unless container_name Dir.mkdir "/sys/fs/cgroup/cpu/#{container_name}" rescue puts("skip") File.write "/sys/fs/cgroup/cpu/#{container_name}/tasks", $$.to_s Dir.chroot "/root/#{container_name}" Dir.chdir "/" system "mount -t proc proc /proc" system "hostname #{container_name}.example.jp" exec "bash -l" ࠷ॳʹɺʮVOTIBSFޙʯͷॲཧΛ3VCZͰॻ͘
Ұ࿈ͷॲཧΛͭͳ͛Δɻ $ sudo unshare \ > --fork \ >
--pid \ > --mount \ > --uts \ > `pwd`/after-unshare.rb railsdm-7th ઌ΄ͲͷεΫϦϓτʹ࣮ߦݖݶΛ͚ͭͯVOTIBSFͷҾʹ
͜Είϯςφʁ wγεςϜ͕%FCJBOͰ͋Δ wϓϩηε͕ಠཱ͍ͯ͠Δɺϗετ໊ҧ͏
ԋशͦͷ w ઌ΄Ͳͷʮࣗ࡞ίϯςφʯʹ͍ͭͯɺ ผͷλʔϛφϧ͔ΒϗετʹೖΓɺҎԼΛ͔֬ΊͯΈΑ͏ɻ w ϗετ͔Βݟͯίϯςφ͕ʮϓϩηεʯͰ͋Δ͜ͱ w
1*%ɺ.PVOUɺ654/BNFTQBDF͕͍ͯ͠Δ͜ͱ w ίϯςφͰ$16Λ͍͘Βͬͯɺϗετͷ$16Λ͔͠ Θͳ͘ͳΔΑ͏ɺDHSPVQΛઃఆͯ͠ΈΑ͏ɻ·ͨɺ֬ೝ͠Α͏ IJOUIUUQTBDDFTTSFEIBUDPNEPDVNFOUBUJPOKB+13FE@)BU@&OUFSQSJTF@-JOVY IUNM
[email protected]
@(VJEFTFDDQVIUNM
॓
·ͱΊ
֮͑ͱ͘͜ͱͭ w-JOVYʹ͓͍ͯɺϓϩηεʹؔ͢Δͨ͘͞Μͷใ͕QSPDͷԼʹ ͋Δ͜ͱ w-JOVYίϯςφɺΧʔωϧͷϦιʔεʮʯͱʮ੍ݶʯͷػೳΛ ͬͨϓϩηεͰ͋Δ͜ͱ
֮͑ͱ͘͜ͱͭ w-JOVYʹ͓͍ͯɺϓϩηεʹؔ͢Δͨ͘͞Μͷใ͕QSPDͷԼʹ ͋Δ͜ͱ w-JOVYίϯςφɺΧʔωϧͷϦιʔεʮʯͱʮ੍ݶʯͷػೳΛ ͬͨϓϩηεͰ͋Δ͜ͱ wͲΜͳʹͦ͠͏ͳπʔϧͰɺ୭͔͕ॻ͍ͨͷͰ͋Γɺ ͦͯ͠044Ͱ͋ΔݶΓதΛਂ͘Δ͜ͱ͕Ͱ͖Δͱ͍͏͜ͱ
ࠓ͞ͳ͔ͬͨ͜ͱ wίϯςφؔ࿈ͷͦͷଞͷػೳͷօ͞Μ wQJWPU@SPPU w,FSOFM$BQBCJMJUZ w3FTPVSDF-JNJU SMJNJU wTFDDPNQ#1' w."$ 4&-JOVY"QQ"SNPS
-JOVY4FDVSJUZ.PEVMFT -4.
ѹతࢀߟจݙ w ϖʔδͷຊΛಡΉલʹಡΜͰ͓͖͍ͨ wʮͳΔ΄Ͳ6OJYϓϩηεʯ wIUUQTUBUTV[JOFDPNCPPLTOBSVIPVOJY
͞ΒͳΔਂΈ w(.0ϖύϘڈͷ࠲ֶࢿྉ wIUUQTTQFBLFSEFDLDPNVE[VSBUIFTLFMUPOPGXIBMFT
13
ίϯςφϨΠϠͷࣄ ԬͰͷࠊΛਾٕ͑ͨज़త ͝ڵຯ͕͋Ε૬ஊʹΓ·͢ GPMMPX!QC@SFDSVJU ͘͠!VE[VSBʹ