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
Write Container Runtime in Go
Search
tomocy
October 28, 2019
Programming
4
3.1k
Write Container Runtime in Go
Presented in Go Conference 2019 Autumn
https://gocon.jp/sessions/write_container_runtime_in_go/
tomocy
October 28, 2019
Tweet
Share
More Decks by tomocy
See All by tomocy
Work around Dart custom lint rule
tomocy
1
410
Other Decks in Programming
See All in Programming
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
RubyLSPのマルチバイト文字対応
notfounds
0
120
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
OSSで起業してもうすぐ10年 / Open Source Conference 2024 Shimane
furukawayasuto
0
100
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.7k
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
910
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
Macとオーディオ再生 2024/11/02
yusukeito
0
370
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
Remix on Hono on Cloudflare Workers
yusukebe
1
290
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Happy Clients
brianwarren
98
6.7k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Practical Orchestrator
shlominoach
186
10k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Rails Girls Zürich Keynote
gr2m
94
13k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
Done Done
chrislema
181
16k
The Language of Interfaces
destraynor
154
24k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Transcript
Write Container Runtime in Go Go Conference 2019 Autumn Koki
Tomoshige (@towocy)
Write Container Runtime in Go
Write Container Runtime in Go
ίϯςφϥϯλΠϜʹ͍ͭͯ
ίϯςφٕज़ ίϯςφϥϯλΠϜͱ ίϯςφΠϝʔδ
ίϯςφϥϯλΠϜ OCI runtimeʹ४ڌ͍ͯ͠Δ
OCIʢOpen Container Initiativeʣ ίϯςφٕज़ͷඪ४ن֨Λ ࡞͢ΔͨΊͷஂମ
None
runtime.me ίϯςφϥϯλΠϜͱͯ͠ͷ ঢ়ଶͱৼΔ͍ https://github.com/opencontainers/runtime-spec/blob/master/runtime.md
Query State state <container-id> Create create <container-id> <path-to-bundle> Start start
<container-id> Kill kill <container-id> <signal> Delete delete <container-id>
None
Standard Go Project Layout /cmd https://github.com/golang-standards/project-layout#cmd
None
CLI pkg github.com/urfave/cli
None
None
None
None
None
InterfaceͰͷநԽ ༻ऀଆ͕ ٻΊΔৼΔ͍Λఆٛ͢Δ https://github.com/golang/go/wiki/CodeReviewComments#interfaces
None
ίϯςφϥϯλΠϜͷ࣮ʹ͍ͭͯ
ίϯςφϥϯλΠϜ ϗετOS্ͷ Ϧιʔεִ͕ɺ੍ݶ͞Εͨϓϩηε
‘Contain’er ʙΛด͡ࠐΊΔ
ίϯςφϥϯλΠϜ How to contain a process
https://employment.en-japan.com/engineerhub/entry/2019/02/05/103000#ίϯςφͱ ΧʔωϧϦιʔεɺϑΝΠϧγεςϜͷִ Namespaceɺchroot/pivot_root ϋʔυΣΞϦιʔεͷ੍ݶ cgroup ݖݶͷ੍ Capabilityɺseccomp
None
Fork
Fork ϓϩηε ࢠϓϩηε
Fork ϓϩηε ࢠϓϩηε Contain
None
Build Constraints ϑΝΠϧ໊Ͱ ϏϧυରΛ͚Δ https://golang.org/pkg/go/build/#hdr-Build_Constraints
None
None
None
None
Fork ϓϩηε ࢠϓϩηε Contain
https://github.com/rrreeeyyy/container-internship/tree/master/02#linux-namespaces IPC ϓϩηεؒ௨৴Ͱ͏Ϧιʔε Network ωοτϫʔΫσόΠεɺϧʔςΟϯάςʔϒϧ Mount ϑΝΠϧγεςϜπϦʔ PID ϓϩηε ID
User Ϣʔβ IDɺάϧʔϓ ID UTS nodenameɺdomainname
None
Fork
None
Filesystem bundle config.jsonͱrootfs https://github.com/opencontainers/runtime-spec/blob/master/bundle.md
ࢠϓϩηεͷϧʔτ༻ʹ
ࢠϓϩηεͷϧʔτ༻ʹ mount͍ͯ͘͠
ࢠϓϩηεͷϧʔτ༻ʹ mount͍͖ͯ͠ ͦͯ͠pivot_root͢Δ
ࢠϓϩηεʹ / ʹݟ͑Δ
cgroup ϓϩηεʹରͯ͠ ڞ௨ͷϦιʔεཧΛ͢Δ https://gihyo.jp/admin/serial/01/linux_containers/0003
None
None
None
None
None
None
None
None
None
None
None
None
Write Container Runtime in Go
͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ
https://github.com/opencontainers/runtime-spec/blob/master/runtime.md https://github.com/opencontainers/runtime-spec/blob/master/bundle.md https://github.com/golang-standards/project-layout#cmd https://github.com/golang/go/wiki/CodeReviewComments#interfaces https://employment.en-japan.com/engineerhub/entry/2019/02/05/103000#ίϯςφͱ https://golang.org/pkg/go/build/#hdr-Build_Constraints https://github.com/rrreeeyyy/container-internship/tree/master/02#linux-namespaces https://employment.en-japan.com/engineerhub/entry/2019/02/05/103000 https://github.com/tomocy/gocon ࢀߟจݙ
https://speakerdeck.com/kyohmizu/windowskontenaru-men?slide=26 https://speakerdeck.com/tenforward/cndt2019 https://sil.hatenablog.com/entry/why-container-is-secure