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
開発者が知っておきたい複雑さの正体/where-the-complexity-comes-from
hanhan1978
8
3.2k
Spec Driven Development入門/spec_driven_development_for_learners
hanhan1978
2
1.4k
フロントエンドがTypeScriptなら、バックエンドはPHPでもいいじゃない/php-is-not-bad
hanhan1978
8
13k
どうすると生き残れないのか/how-not-to-survive
hanhan1978
17
14k
100分で本番デプロイ!Laravelで作るWebアプリケーション作成/100min_web_app_cicd
hanhan1978
1
230
PHPerのための計算量入門/Complexity101 for PHPer
hanhan1978
8
3.4k
集中して作業する技術/how_to_work_deeply
hanhan1978
65
54k
PHPでデータベースを作ってみた/create-data-with-php
hanhan1978
11
11k
ADRを一年運用してみた/adr_after_a_year
hanhan1978
8
4.6k
Other Decks in Programming
See All in Programming
実は歴史的なアップデートだと思う AWS Interconnect - multicloud
maroon1st
0
310
re:Invent 2025 のイケてるサービスを紹介する
maroon1st
0
160
Combinatorial Interview Problems with Backtracking Solutions - From Imperative Procedural Programming to Declarative Functional Programming - Part 2
philipschwarz
PRO
0
130
AI Agent Tool のためのバックエンドアーキテクチャを考える #encraft
izumin5210
6
1.6k
Context is King? 〜Verifiability時代とコンテキスト設計 / Beyond "Context is King"
rkaga
10
1.5k
16年目のピクシブ百科事典を支える最新の技術基盤 / The Modern Tech Stack Powering Pixiv Encyclopedia in its 16th Year
ahuglajbclajep
2
550
The Art of Re-Architecture - Droidcon India 2025
siddroid
0
160
例外処理とどう使い分ける?Result型を使ったエラー設計 #burikaigi
kajitack
16
4.8k
組み合わせ爆発にのまれない - 責務分割 x テスト
halhorn
1
180
Pythonではじめるオープンデータ分析〜書籍の紹介と書籍で紹介しきれなかった事例の紹介〜
welliving
3
770
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
660
大規模Cloud Native環境におけるFalcoの運用
owlinux1000
0
240
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
330
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.6k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
92
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
200
Utilizing Notion as your number one productivity tool
mfonobong
2
190
エンジニアに許された特別な時間の終わり
watany
106
220k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
40
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
690
[RailsConf 2023] Rails as a piece of cake
palkan
58
6.2k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
210
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
Ҏ্ɺ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ