Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Dockerを使ってみよう / #kosenconf131hokkaido
Search
さたけ
August 17, 2019
200
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Dockerを使ってみよう / #kosenconf131hokkaido
さたけ
August 17, 2019
More Decks by さたけ
See All by さたけ
Packer で自分だけの Raspberry Pi イメージを 作った話 / #techstudygroupjp 2020.5.14
satackey
0
440
GitHubとCircleCIで過去問管理 / #aosc 2019-12-21
satackey
0
81
Cloud Foundry を使ってみた / #aosc 2018-02-23
satackey
0
37
Featured
See All Featured
Designing for Timeless Needs
cassininazir
1
510
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.8k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.3k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
250
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
290
Code Reviewing Like a Champion
maltzj
528
40k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
570
Done Done
chrislema
187
17k
How to Talk to Developers About Accessibility
jct
2
560
It's Worth the Effort
3n
188
29k
Transcript
DockerΛ ͬͯΈΑ͏ ࠤ ߤر
ࣗݾհ • খߴઐ 2 ใܥ • ߴઐϓϩίϯڝٕ෦ • AtCoder(Python)ɺ WebϑϩϯτΤϯυɺ
όοΫΤϯυ ͳͲ͍Ζ͍Ζ… @satakenkoki
ࠓͷඪ • DockerΛΒͳ͍ਓɺॳ৺ऀͷਓʹ ͔Δʙ͘ɺΘ͔ͬͯΒ͏ɻ (DockerΛ͍͜ͳͯ͠Δਓɺؒҧ͍ͬͯΔ ͱ͜Ζ͕͋Εࢦఠͯ͘͠ΕΔͱخ͍͠Ͱ͢)
ԾԽͱʁ
• ͬ͘͟Γݴ͏ͱɺ̍ͷίϯϐϡʔλΛɺ ෳ͋Δ͔ͷ༷ʹ͏͜ͱɻ https://www.infraexpert.com/study/virtual.html
ࣗͷPCͷ্ʹ ͞ΕͨڥΛ࡞ΕΔ
• ͬ͘͟Γݴ͏ͱɺ̍ͷίϯϐϡʔλΛɺ ෳ͋Δ͔ͷ༷ʹ͏͜ͱɻ https://www.infraexpert.com/study/virtual.html ήετଆ ϗετଆ
Dockerͱʁ
https://www.docker.com/resources/what-container ͦΕͧΕʹ ͋Δ͔Β ແବ ࠓ·ͰͷԾԽ
• ͬ͘͟Γݴ͏ͱɺ̍ͷίϯϐϡʔλΛɺ ෳ͋Δ͔ͷ༷ʹ͏͜ͱɻ https://www.infraexpert.com/study/virtual.html
https://www.docker.com/resources/what-container ͦΕͧΕʹ ͋Δ͔Β ແବ ࠓ·ͰͷԾԽ
ίϯςφܕԾԽ https://www.docker.com/resources/what-container ࠓ·ͰͷԾԽ ແବ͕ͳ͘ͳͬͨ
ແବ͕ͳ͍ ↓ Ϧιʔεফඅྔ͕গͳ͍ σΟεΫ༻ྔ͕গͳ͍ ↓ ίϯϐϡʔλʹ༏͍͠
ࣗͷPCͷ্ʹ ͞ΕͨڥΛ ܰྔʹ ࡞ΕΔ
ίϯςφܕԾԽ https://www.docker.com/resources/what-container ࠓ·ͰͷԾԽ
Dockerίϯςφͱݺͼ·͢ https://www.docker.com/resources/what-container
Dockerίϯςφͱݺͼ·͢ https://www.docker.com/resources/what-container Dockerίϯςφ DockerΠϝʔδΛݩʹ ىಈ͞Ε·͢
Docker ΠϝʔδΛ༻ҙ͢Δ • Docker Hubͱ͍͏αʔϏεʹ ͨ͘͞Μͷਓ͕࡞ͬͨɺ ༷ʑͳΠϝʔδ͕ެ։͞Ε͍ͯ·͢ɻ • DockerfileΛ͍ɺDocker HubͷΠϝʔδΛݩʹ
ࣗͰDockerΠϝʔδΛ࡞Δ͜ͱͰ͖·͢ɻ • ࣗͰ࡞ͬͨΠϝʔδΛެ։͢Δ͜ͱͰ͖·͢ɻ
PythonΛಈ͔ͯ͠ΈΔ print("Hello, world") # pythonͷΠϝʔδΛݩʹ͢Δ FROM python:3.7 # Helloworld.pyΛίϯςφʹίϐʔ COPY
helloworld.py / # ίϯςφىಈ࣌ʹ࣮ߦ͢ΔίϚϯυΛࢦఆ CMD ["python", "/helloworld.py"] Dockerfile Helloworld.py
͜ͷ̎ͭͷϑΝΠϧΛ ಉ͡ॴʹஔ͖·͢
$ # Docker ΠϝʔδΛ $ # python-hello-world ͱ͍͏໊લͰ࡞͢Δ $ docker
build -t python-hello-world . # ...লུ $ # python-hello-world ͱ͍͏ $ # DockerΠϝʔδΛ࣮ߦ͢Δ $ docker run python-hello-world Hello, world
DockerͷϝϦοτ • DockerfileͳͲΛ༻͍Δ͜ͱʹΑΓɺ ಉ͡ίʔυ͔Βಉ͡ڥΛ؆୯ʹ࡞ΕΔ • ࠓ·ͰͷԾԽΑΓɺ༰ྔ͕গͳ͍ͷͰ ڞ༗͕༰қ
DockerͰ࣮ߦͰ͖͚ͨͲɺ ࡞ͨ͠ϑΝΠϧͲ͏͢Δ?
ਵ࣌มΘΔσʔλ?
Bind mounts / Volumes • Bind mounts ϗετͷϑΝΠϧɾσΟϨΫτϦΛ ίϯςφʹϚϯτ͢Δػೳ •
Volumes Docker͕ཧ͢ΔྖҬΛ ίϯςφʹϚϯτ͢Δػೳ
Bind mounts / Volumes • Bind mounts ϗετͷϑΝΠϧɾσΟϨΫτϦΛ ίϯςφʹϚϯτ͢Δػೳ •
Volumes Docker͕ཧ͢ΔྖҬΛ ίϯςφʹϚϯτ͢Δػೳ ίϚϯυ࣮ߦ࣌ʹ -v /path/to/dir:/path/to/conteiner
$ # Docker ΠϝʔδΛ $ # python-hello-world ͱ͍͏໊લͰ࡞͢Δ $ docker
build -t python-hello-world . # ...লུ $ # python-hello-world ͱ͍͏ $ # DockerΠϝʔδΛ࣮ߦ͢Δ $ docker run python-hello-world Hello, world ͖࣮ͬ͞ߦͨ͠ίʔυ
$ docker run \ # ݱࡏͷσΟϨΫτϦΛίϯςφͷ/dirʹϚϯτ -v ${PWD}:/dir \ python:3.7
\ # ࣮ߦ͢ΔίϚϯυ python /dir/helloworld.py Hello, world Bind mount Λ͑͜Ε͚ͩ
DockerίϯςφΛ͏ͱ͖ • DockerͷίϯςφΛѻ͏ࡍɺ σʔλ֎෦ʹஔ͘ͷ͕جຊ • 1ίϯςφ1ϓϩηε͕جຊ →࠶ར༻ͳͲ͕؆୯ʹͳΔ
͞Βʹ • DockerΛͬͯɺࣗͷΞϓϦέʔγϣϯΛ ެ։͢Δ • Dockerͷڥ͑͋͞Εɺ ෳࡶͳઃఆͳ͠ʹ୭Ͱಈ͔ͤΔ
·ͱΊ • DockerܰྔͰɺ͞ΕͨڥΛ࡞ΕΔ • DockerfileͳͲΛͬͯɺDockerΠϝʔδΛ ࡞͠ɺDockerίϯςφΛ࡞͢Δ • ڥͷڞ༗࠶ߏங͕༰қ
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠!