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
82
Cloud Foundry を使ってみた / #aosc 2018-02-23
satackey
0
40
Featured
See All Featured
HDC tutorial
michielstock
2
970
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
530
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
Design in an AI World
tapps
1
360
Ruling the World: When Life Gets Gamed
codingconduct
0
410
Writing Fast Ruby
sferik
630
63k
Believing is Seeing
oripsolob
1
250
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Abbi's Birthday
coloredviolet
4
10k
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ίϯςφΛ࡞͢Δ • ڥͷڞ༗࠶ߏங͕༰қ
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠!