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
Introduction to Docker
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Yukiyan
October 16, 2015
Programming
5.8k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction to Docker
社内勉強会(2015/10/16)
Yukiyan
October 16, 2015
More Decks by Yukiyan
See All by Yukiyan
Introduction to Scala about type parameter
yukiyan
0
170
Introduction to Scala
yukiyan
0
110
digdagで支えるデータパイプライン / Building a data pipeline with digdag
yukiyan
1
5.9k
機械学習基盤を一人で構築するということ / Hitori ml team
yukiyan
3
3.7k
ECSのデプロイツールを試している話
yukiyan
0
2.5k
Replace a batch application to ECS
yukiyan
1
1.6k
Other Decks in Programming
See All in Programming
AI Engineeringは、AIプロダクトだけのものか? 〜AIがソフトウェアを作る時代の新しい当たり前〜 / No AI in your product. AI Engineering in your development.
rkaga
5
510
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
200
Pythonの実行はどこまで賢くなったのか? CPythonとPyPyから見る最適化のしくみ
curekoshimizu
3
1.7k
PostgreSQL 18で考えるUUID主キー
kazuhiro1982
0
500
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
370
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
360
Loosening the Reins: Go Generics Get More Flexible
kuro_kurorrr
0
290
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
310
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
430
KotlinConf Extended South Korea 2026 Keynote
l2hyunwoo
0
120
源内ハンズオン概要編
hideg
0
210
不幸な GC
chencmd
0
650
Featured
See All Featured
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Unsuck your backbone
ammeep
672
58k
How GitHub (no longer) Works
holman
316
150k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
64
56k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
970
The Curious Case for Waylosing
cassininazir
1
480
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Prompt Engineering for Job Search
mfonobong
0
410
Automating Front-end Workflow
addyosmani
1369
210k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
660
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Transcript
Introduction to Docker
Why choose this topic?
Big Wave Coming
Big Wave in ࣾ • Docker swarmͷػӡ • Docker࣮ફೖ(Dockerຊ)ͷ·Γ •
ͷνʔϜʹDocker৬ਓ͕͍Δ
Big Wave in the ੈք • Dockerʹؔ࿈༷ͨ͠ʑͳπʔϧͷొ • Docker Machine
• Docker swarm • Docker compose
·͍ͣ
Goal • DockerͷಛɾརΛཧղ͢Δ͜ͱ • DockerfileΛॻ͍ͯϏϧυ͢Δ·Ͱͷ؆୯ͳྲྀΕΛཧղ͢Δ ͜ͱ • Dockerʹ͓͚ΔσΟεΫΠϝʔδཧػೳɾϓϩηεཧ
DockerͷಛɾརΛ ཧղ͢Δ
What is Docker?
What is Docker? • Dockerࣾ ͕ΦʔϓϯιʔεͰެ։͍ͯ͠Δɺίϯςφٕज़ʹ ΑΔԾԽιϑτΣΞ • LXC(Linux Container),
AUFS(Another Union FS) • Vagrantͱൺֱͯ͠ىಈ͕͍ɻ
What is Container?
※ ※ ը૾Ҿ༻ݩ: http://www.slideshare.net/TrisM/docker-41045742 P22
Benefit • σϓϩΠ͕खܰʹͳΔ • εέʔϥϏϦςΟɾߴޮɾ൚༻ੑ
Use Case • ΞϓϦέʔγϣϯ • DB • Ϗϧυڥ • ͍Ζ͍ΖͳΜͰ
※ ※ ը૾Ҿ༻ݩ: http://www.slideshare.net/TrisM/docker-41045742 P22
DockerfileΛॻ͍ͯϏϧ υ͢Δ·Ͱͷ؆୯ͳྲྀΕ Λཧղ͢Δ
flow 1. Dockerfileॻ͘ 2. Ϗϧυ͢Δ 3. docker run͢Δ 4. ϨδετϦpush
1. Dockerfileॻ͘ FROM yukiyan_w/centos:centos6 MAINTAINER Yuki Wakayama RUN yum -y
install httpd RUN echo 'Hello, World!!' > /var/www/html/index.html ADD init.sh /usr/local/bin/init.sh RUN chmod u+x /usr/local/bin/init.sh CMD ["/usr/local/bin/init.sh"]
#!/bin/bash service httpd start /bin/bash
2. Ϗϧυ͢Δ docker build -t yukiyan_w/apache:ver1.0 . Πϝʔδ͕Ͱ͖Δ docker@dev:~$ docker
images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE yukiyan_w/apache ver1.0 e0bd562a2d43 1 days ago 264.1 MB yukiyan_w/centos centos6 a005304e4e74 1 days ago 203.1 MB
3. docker run͢Δ docker run -itd -p 8000:80 --name apache01
yukiyan_w/apache:ver1.0 ಈ͍ͯΔ͔֬ೝ docker@dev:~$ docker attach apache01 [root@3a607e0dd9f9 /]# ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 15:09 ? 00:00:00 /bin/bash /usr/local/bin/init.sh root 17 1 0 15:09 ? 00:00:00 /usr/sbin/httpd root 19 1 0 15:09 ? 00:00:00 /bin/bash apache 20 17 0 15:09 ? 00:00:00 /usr/sbin/httpd apache 21 17 0 15:09 ? 00:00:00 /usr/sbin/httpd apache 22 17 0 15:09 ? 00:00:00 /usr/sbin/httpd root 36 19 0 15:10 ? 00:00:00 ps -ef
4. ϨδετϦpush docker push yukiyan_w/apache
flow • Dockerfileॻ͘ɺϏϧυ͢Δɺ docker runɺ͍͡Δɺcommitɺtag ͚ͭΔɺϨδετϦ • DockerHub͔Βpull͢Δɺdocker runɺ͍͡Δɺcommitɺtag͚ͭΔɺ ϨδετϦ
※ ※ ը૾Ҿ༻ݩ: http://www.slideshare.net/TrisM/docker-41045742 P22
Cache for Faster Builds • DockerΠϝʔδΛࠩཧͯ͠ΔͷͰϏϧυ͕ૣ͍
docker build -t yukiyan_w/apache:ver1.0 . Step 0 : FROM yukiyan_w/centos:centos6
centos6: Pulling from yukiyan_w/centos Status: Downloaded newer image for yukiyan_w/centos:centos6 ---> a005304e4e74 Step 1 : MAINTAINER Yuki Wakayama ---> Running in 0eec2e2e93d1 ---> 2477c45cfa23 Removing intermediate container 0eec2e2e93d1 Step 2 : RUN yum -y install httpd ---> Running in 9dd64b9d2aeb ---> c09ed7b982db Removing intermediate container 9dd64b9d2aeb Step 3 : RUN echo 'Hello, World!!' > /var/www/html/index.html ---> Running in b8972fb573a7 ---> 9cd9b8077c76 Removing intermediate container b8972fb573a7 Step 4 : ADD init.sh /usr/local/bin/init.sh ---> 998ad3b60ab3 Removing intermediate container 23e41b8192c4 Step 5 : RUN chmod u+x /usr/local/bin/init.sh ---> Running in 2be75c857f5c ---> 5726cae34e32 Removing intermediate container 2be75c857f5c Step 6 : CMD /usr/local/bin/init.sh Successfully built e0bd562a2d4
ͪΐͬͱม͑Δ FROM yukiyan_w/centos:centos6 MAINTAINER Yuki Wakayama RUN yum -y install
httpd RUN echo 'Hello, World!!' > /var/www/html/index.html ADD init.sh /usr/local/bin/init.sh RUN chmod u+x /usr/local/bin/init.sh + RUN echo 'Hello, World!!' CMD ["/usr/local/bin/init.sh"]
Step 0 : FROM yukiyan_w/centos:centos6 ---> a005304e4e74 Step 1 :
MAINTAINER Yuki Wakayama ---> Using cache ---> 2477c45cfa23 Step 2 : RUN yum -y install httpd ---> Using cache ---> c09ed7b982db Step 3 : RUN echo 'Hello, World!!' > /var/www/html/index.html ---> Using cache ---> 9cd9b8077c76 Step 4 : ADD init.sh /usr/local/bin/init.sh ---> Using cache ---> 998ad3b60ab3 Step 5 : RUN chmod u+x /usr/local/bin/init.sh ---> Using cache ---> 5726cae34e32 Step 6 : RUN echo 'Hello, World!!' ---> Running in 4191d60ea4b0 Hello, World!! ---> c87043d1219f Removing intermediate container 4191d60ea4b0 Step 7 : CMD /usr/local/bin/init.sh ---> Running in 52aef5dab4ce ---> 042133d33472 Removing intermediate container 52aef5dab4ce Successfully built 042133d33472
!
But ⾠
yum update໋ྩΩϟογϡ͞ΕΔͷͰ`--no-cacheͱ͔͠ͳ ͍ͱ࣍ճϏϧυ࣌ʹ࠷৽ͷঢ়ଶʹΞοϓσʔτ͞Εͳ͍
Progress • DockerͷಛɾརΛཧղ͢Δ͜ͱ Done ✅ • DockerfileΛॻ͍ͯϏϧυ͢Δ·Ͱͷ؆୯ͳྲྀΕΛཧղ͢Δ ͜ͱ Done ✅
• Dockerʹ͓͚ΔσΟεΫΠϝʔδཧػೳɾϓϩηεཧ
ਫΛҿΉ࣌ؒ !
Dockerʹ͓͚ΔσΟεΫΠϝʔδཧ ػೳɾϓϩηεཧ
σΟεΫΠϝʔδཧػೳ
͖ͬ͞ɾɾɾ
FROM yukiyan_w/centos:centos6 MAINTAINER Yuki Wakayama RUN yum -y install httpd
RUN echo 'Hello, World!!' > /var/www/html/index.html ADD init.sh /usr/local/bin/init.sh RUN chmod u+x /usr/local/bin/init.sh CMD ["/usr/local/bin/init.sh"] ↓ docker build -t yukiyan_w/apache:ver1.0 .
FROM yukiyan_w/centos:centos6 DockerfileͰॻ͍ͯΔ͚ͲɺϏϧυcentos7Ͱߦͬͨ
• ίϯςφ෦ͰCentOS6͕ήετOS ͱͯ͠ಈ͍ͯΔΘ͚Ͱͳ͍ • ίϯςφ෦ͰCentOS6ͷڥͱ ಉ͡σΟεΫͷ༰͕ݟ͑Δ • CentOS6ͷσΟεΫʹೖͬͯΔόΠ φϦ/usr/sbin/httpd͔ΒσʔϞϯ ϓϩηεΛىಈ͢Δ
ήετOSͷىಈϓϩηεΛলུͯ͠ɺ తͷΞϓϦέʔγϣϯ͚ͩىಈ ͢Δ͜ͱ͕Ͱ͖Δ
͔ͩΒ͍
Dockerʹ͓͚ΔσΟεΫΠϝʔδཧػೳ Doneɾϓϩηε ཧ
ϓϩηεཧ
ෳཱͯͨίϯςφɺͦΕͧΕಠཱͨ͠ϓϩηεςʔϒϧ͕ ׂΓͯΒΕΔ
͖ͬ͞ݴͬͨ ήετOSͷىಈϓϩηεΛলུͯ͠ɺతͷΞϓϦέʔγϣϯ ͚ͩىಈ͢Δ͜ͱ͕Ͱ͖Δ
తͷΞϓϦέʔγϣϯ FROM yukiyan_w/centos:centos6 MAINTAINER Yuki Wakayama RUN yum -y install
httpd RUN echo 'Hello, World!!' > /var/www/html/index.html ADD init.sh /usr/local/bin/init.sh RUN chmod u+x /usr/local/bin/init.sh CMD ["/usr/local/bin/init.sh"]
ήετOSͷىಈϓϩηεΛলུͯ͠ɺతͷΞϓϦέʔγϣϯ ͚ͩىಈ͢Δ͜ͱ͕Ͱ͖Δ ↓ తͷΞϓϦέʔγϣϯ͕ PID=1 Ͱىಈ͞ΕͯΔͣ
docker@dev:~$ docker run -itd -p 8000:80 --name apache01 yukiyan_w/apache:ver1.0 docker@dev:~$
docker attach apache01 [root@3a607e0dd9f9 /]# ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 15:09 ? 00:00:00 /bin/bash /usr/local/bin/init.sh root 17 1 0 15:09 ? 00:00:00 /usr/sbin/httpd root 19 1 0 15:09 ? 00:00:00 /bin/bash apache 20 17 0 15:09 ? 00:00:00 /usr/sbin/httpd apache 21 17 0 15:09 ? 00:00:00 /usr/sbin/httpd apache 22 17 0 15:09 ? 00:00:00 /usr/sbin/httpd root 36 19 0 15:10 ? 00:00:00 ps -ef Dockerfileͷ࠷ऴߦͷίϚϯυ͕PID=1Ͱಈ͍ͯΔʂʂ CMD ["/usr/local/bin/init.sh"]
ϗετOS͔Βݟ͑Δϓϩηε docker@dev:~$ ps -ef UID PID PPID C STIME TTY
TIME CMD ʙ(Ұ෦লུ)ʙ root 1019 1 0 06:14 ? 00:00:42 /usr/local/bin/docker daemonɹলུ root 9832 1019 0 16:54 ? 00:00:00 docker-proxy -proto tcp লུ root 9844 1019 0 16:54 pts/1 00:00:00 /bin/bash /usr/local/bin/init.sh root 9862 9844 0 16:54 ? 00:00:00 /usr/sbin/httpd root 9864 9844 0 16:54 pts/1 00:00:00 /bin/bash 48 9865 9862 0 16:54 ? 00:00:00 /usr/sbin/httpd 48 9867 9862 0 16:54 ? 00:00:00 /usr/sbin/httpd 48 9868 9862 0 16:54 ? 00:00:00 /usr/sbin/httpd docker 9882 7689 0 16:54 pts/0 00:00:00 ps -ef ίϯςφͰಈ͍ͯΔϓϩηεݟ͑Δ͚ͲɺPID͕ҧ͏ʂʂ
None
Dockerʹ͓͚ΔσΟεΫΠϝʔδཧػೳ Doneɾϓϩηε ཧ Done
Progress ! • DockerͷಛɾརΛཧղ͢Δ͜ͱ Done ✅ • DockerfileΛॻ͍ͯϏϧυ͢Δ·Ͱͷ؆୯ͳྲྀΕΛཧղ͢Δ ͜ͱ Done
✅ • Dockerʹ͓͚ΔσΟεΫΠϝʔδཧػೳɾϓϩηεཧ Done ✅
Summary
Summary • DockerͷಛɾརΛཧղ͢Δ͜ͱ • Vagrantͱൺֱͯ͠ىಈ͕͍ɻ • ίϯςφͷ߹ɺԾϚγϯήετOSͱ͍͏ߟ͑ํ ͋Γ·ͤΜɻ • σϓϩΠ͕खܰʹͳΔ
• εέʔϥϏϦςΟɾߴޮɾ൚༻ੑ
Summary • DockerfileΛॻ͍ͯϏϧυ͢Δ·Ͱͷ؆୯ͳྲྀΕΛཧղ͢Δ ͜ͱ 1. Dockerfileॻ͘ 2. Ϗϧυ͢Δ 3. docker
run͢Δ 4. ϨδετϦpush
Summary • Dockerʹ͓͚ΔσΟεΫΠϝʔδཧػೳɾϓϩηεཧ • ήετOSͷىಈϓϩηεΛলུͯ͠ɺతͷΞϓϦέʔ γϣϯ͚ͩىಈ͢Δ͜ͱ͕Ͱ͖Δ • ϗετOS͔Βίϯςφͷϓϩηε͕ݟ͑Δ͚Ͳɺίϯ ςφ͔ΒϗετOSͷϓϩηεݟ͑ͳ͍
Next time... • Ԡ༻తͳ෦ • σʔλͷӬଓԽ • ࢹɺϩΪϯά • ωοτϫʔΫ
• पลٕज़ • swarm, compose • k8s, ECS
Build, Run, Enjoy !
Thanks for listening!