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
コンテナを雰囲気で動かさない話
Search
Ryo Tomidokoro
June 15, 2018
Programming
11
5.4k
コンテナを雰囲気で動かさない話
PHPカンファレンス福岡2018前夜祭リジェクトコン
Ryo Tomidokoro
June 15, 2018
Tweet
Share
More Decks by Ryo Tomidokoro
See All by Ryo Tomidokoro
フロントエンドがTypeScriptなら、バックエンドはPHPでもいいじゃない/php-is-not-bad
hanhan1978
9
13k
どうすると生き残れないのか/how-not-to-survive
hanhan1978
17
14k
100分で本番デプロイ!Laravelで作るWebアプリケーション作成/100min_web_app_cicd
hanhan1978
1
180
PHPerのための計算量入門/Complexity101 for PHPer
hanhan1978
8
3k
集中して作業する技術/how_to_work_deeply
hanhan1978
65
50k
PHPでデータベースを作ってみた/create-data-with-php
hanhan1978
11
10k
ADRを一年運用してみた/adr_after_a_year
hanhan1978
8
4.3k
B+木入門:PHPで理解する データベースインデックスの仕組み/b-plus-tree-101
hanhan1978
5
5.4k
ADRを一年運用してみた/our_story_about_adr
hanhan1978
5
2.4k
Other Decks in Programming
See All in Programming
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
190
A Gopher's Guide to Vibe Coding
danicat
0
170
GUI操作LLMの最新動向: UI-TARSと関連論文紹介
kfujikawa
0
1k
ワープロって実は計算機で
pepepper
2
1.4k
MCPで実現するAIエージェント駆動のNext.jsアプリデバッグ手法
nyatinte
7
910
Understanding Ruby Grammar Through Conflicts
yui_knk
1
140
未来を拓くAI技術〜エージェント開発とAI駆動開発〜
leveragestech
2
180
あなたとJIT, 今すぐアセンブ ル
sisshiki1969
1
730
Namespace and Its Future
tagomoris
6
510
Flutter로 Gemini와 MCP를 활용한 Agentic App 만들기 - 박제창 2025 I/O Extended Seoul
itsmedreamwalker
0
150
CSC305 Summer Lecture 06
javiergs
PRO
0
100
250830 IaCの選定~AWS SAMのLambdaをECSに乗り換えたときの備忘録~
east_takumi
0
250
Featured
See All Featured
Producing Creativity
orderedlist
PRO
347
40k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Faster Mobile Websites
deanohume
309
31k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.6k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
480
BBQ
matthewcrist
89
9.8k
How to train your dragon (web standard)
notwaldorf
96
6.2k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
900
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
Done Done
chrislema
185
16k
Transcript
ίϯςφΛงғؾͰಈ͔͞ͳ͍ 1)1ΧϯϑΝϨϯεԬલࡇϦδΣΫτίϯ *OOPWBUPS+BQBO*OD ॴ྄ &OHJOFFS
ͬͦ͘͞Ͱ͕͢
ίϯςφΛงғؾͰͬͯ·ͤΜ͔ʁ
DockerΛͬͨ։ൃ ίϯςφͷৄࡉΒͳͯ͘ग़དྷΔ
ڥߏங docker-compose.yml
docker-compose up -d ։ൃڥߏங͕Ұॠ…
docker-compose down ࠔͬͨΒ্ཱͪ͛͠ docker-compose up -d
͜ͷ··ͰΞϗʹͳΔʂ ຊΛಡΜͰίϯςφʹೖͩ
ίϯςφԾԽɺαʔόʔԾԽͰͳ͍ɻ Α͋͘Δίϯςφೖॻͷಋೖ෦
ผʹαʔόʔԾԽͷ͜ͱʹৄ͘͠ͳΓ͍ͨΘ ͚Ͱͳ͍ͷ͕ͩ…
ίϯςφͱΧʔωϧͷఏڙ͢ΔػೳʹΑͬͯ ࣮ߦڥ͕͞ΕͨͦΕͧΕͷϢʔβۭؒͷ ͜ͱͰ͋Δɻ -> ͜͏͍͏આ໌͚ͩͩͱϐϯͱ͜ͳ͍ Α͋͘Δίϯςφೖॻͷಋೖ෦
݁ہɺίϯςφ͕Α͔͘Βͳ͍
ਅ໘ͳ શһ͕ৄࡉΛ͠Βͳͯ͘ଟ͍͍ நతʹѻ͑ΔͳΒͦΕ͍͍
ͰɺࢲΓ͍ͨ Ͳ͏ͳ͍ͬͯΔͷ͔ཧղ͍ͨ͠
ͦ͜ͰࣗͳΓʹௐͨ
chroot 1979 ~ unshare 2.14~ nsenter 2.6.24~ cgroups 2.6.24~ ԶௐʹΑΔίϯςφͷਖ਼ମ
※LinuxͷίϚϯυͰ͢ɻ
Ҏ্Ͱ͢… ͱ͍͏ͷڐ͞Εͳ͍ͱࢥ͏ͷͰɻ ྫΛަ͑ͯɺͳΔ͘ฏқʹઆ໌͠·͢ɻ
ྫ͑ɺ `alpine linux` ίϯςφ tarͷதʢൈਮ)
ͯ͞ɺ͜Ε͕Ͳ͏ͬͯಈ͘ͷ͔ʁ
chroot ͍͖ͳΓίϯςφ
ͨͩ͠ɺ͜Ε͚ͩͩͱ͕ෆे ↑ϗετͷϓϩηεΛpkillͰ͖ͪΌ͏
unshare namespaceΛ࡞ͯ͠ɺϓϩηεΛ
cgroups /sys/fs/cgroupԼͰઃఆΛݟΕΔ ϓϩηεάϧʔϓͷϦιʔεར༻Λִɾ੍ݶ
unshare͞ΕͨϓϩηεʹೖΕΔ `name space enter` `docker exec` ͱ͔ʹΘΕ͍ͯΔͱࢥ͏ nsenter
ίϯςφΛ࣮ݱ͢Δ4ίϚϯυ جຊ chroot ϓϩηεΛ unshare Ͱ ϦιʔεΛ cgroup Ͱ nsenter
Ͱͨ͠ϓϩηεʹ৵ೖ
جຊ chroot Linux͔ΒɺLinuxͰ࣮ߦՄೳͳϑΝΠϧΛ࣮ߦ
྆ํLinux͔ͩΒ࣮ߦͰ͖Δ LinuxΧʔωϧͷABI Application Binary Interface ݫ֨ͳޙํޓੑ
Ұݟ alpinelinux ͕ԾOSͷΑ͏ʹݟ͑Δ ࣮ଶϓϩηε࣮ߦ
ɹchrootdocker ࣮ߦ࣌ʹɺඞͣίϚϯυΛࢦఆ docker run -it alpine:latest sh ͦ͏͍͏͜ͱͩͬͨͷ͔…
ίϯςφग़ͨͯͷ͜Ζ ୡਓ͕͓ͨͪͬ͠Όͬͯ·ͨ͠ɻ ʮίϯςφͬͯ chrootͩΑͶʯͱ Α͏͘…ҙຯΛཧղͰ͖·ͨ͠
͔͠͠ɺผͷ͕༙͍ٙͯ͘Δ
Docker For Mac ʁ Docker For Windows ? MacɺWindowsLinux͡Όͳ͍
ͳΜͰ Dockerಈ͘ͷʁ
Docker for Mac Windowsͷ߹ಉ༷ LinuxKitͱ͍͏ίϯςφ༻Linux্Ͱಈ࡞
ྫ͑ MacͷClangͰ HelloWorldͷ࣮ߦϑΝΠϧΛ࡞ Linuxίϯςφ্Ͱ࣮ߦ -> ಈ͔ͳ͍ɻ Linux͡Όͳ͍͔Βɻ
UbuntuͰ HelloWorldͷ࣮ߦϑΝΠϧΛ࡞ DockerͰ࣮ߦ -> ಈ͘
Linux -> Linuxͷ࣮ߦՄೳϑΝΠϧ -> ಈ͘ Linux -> OSXͷ࣮ߦՄೳϑΝΠϧ -> ಈ͔ͳ͍
ཧ۶୯७
LXCͱ͔LibContainerͱ͔runCͱ͔ Containerdͱ͔৭ʑมΘ͍ͬͯͬͯΔ͕ جຊมΘΒͳ͍ɻ
͜͜·ͰΛཧղ͢Ε DockerͰಈ࡞͢Δ Windowsίϯςφ͕ແ͍ཧ༝ OSXίϯςφ͕ແ͍ཧ༝ શʹ͔Γ·͢ΑͶʁ
ίϯςφ Linux ͔Β Linuxͷ࣮ߦՄೳϑΝΠϧΛಈ͔ٕ͢ज़͔ͩΒ
͕࣌ؒ༨ͬͯͨΒDEMO
Ҏ্ɺ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ