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
Dockerを使ってみよう / #kosenconf131hokkaido
Search
さたけ
August 17, 2019
0
200
Dockerを使ってみよう / #kosenconf131hokkaido
さたけ
August 17, 2019
Tweet
Share
More Decks by さたけ
See All by さたけ
Packer で自分だけの Raspberry Pi イメージを 作った話 / #techstudygroupjp 2020.5.14
satackey
0
420
GitHubとCircleCIで過去問管理 / #aosc 2019-12-21
satackey
0
73
Cloud Foundry を使ってみた / #aosc 2018-02-23
satackey
0
29
Featured
See All Featured
How Software Deployment tools have changed in the past 20 years
geshan
0
32k
[SF Ruby Conf 2025] Rails X
palkan
2
820
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
290
First, design no harm
axbom
PRO
2
1.1k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
110
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
440
Darren the Foodie - Storyboard
khoart
PRO
3
2.8k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
150
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
120
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ίϯςφΛ࡞͢Δ • ڥͷڞ༗࠶ߏங͕༰қ
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠!