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入門
Search
imtnd
April 24, 2016
Technology
0
980
Docker入門
NaITE 13回目勉強会 Docker入門 資料
imtnd
April 24, 2016
Tweet
Share
More Decks by imtnd
See All by imtnd
グローバルなソフトウェアテスト組織における課題と戦略 / Challenges and Strategies in a Global Software Testing Organization #mf_techday
imtnd
0
370
WACATE 2022 夏 ワークショップの目的
imtnd
0
970
テスト設計技法をなぜ&どのように使うのか体験しよう!
imtnd
0
1.5k
analyze the behavior with decision table
imtnd
0
4.1k
WACATE流テスト分析のワークショップを体感してみよう
imtnd
0
210
テスト技法作成のアプローチを考える
imtnd
0
720
テストの目的を考えよう
imtnd
0
800
アジャイルとテスト / Agile and Testing
imtnd
1
1.9k
やってみよう状態遷移テスト #xpjug
imtnd
0
1k
Other Decks in Technology
See All in Technology
AWS環境におけるランサムウェア攻撃対策の設計
nrinetcom
PRO
0
180
C++26 エラー性動作
faithandbrave
2
820
DevFest 2024 Incheon / Songdo - Compose UI 조합 심화
wisemuji
0
160
なぜCodeceptJSを選んだか
goataka
0
180
APIとはなにか
mikanichinose
0
120
生成AIのガバナンスの全体像と現実解
fnifni
1
210
TSKaigi 2024 の登壇から広がったコミュニティ活動について
tsukuha
0
170
多様なメトリックとシステムの健全性維持
masaaki_k
0
120
PHPerのための計算量入門/Complexity101 for PHPer
hanhan1978
5
700
Work as an App Engineer
lycorp_recruit_jp
0
370
私なりのAIのご紹介 [2024年版]
qt_luigi
1
120
サーバーなしでWordPress運用、できますよ。
sogaoh
PRO
0
120
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
A better future with KSS
kneath
238
17k
Automating Front-end Workflow
addyosmani
1366
200k
A designer walks into a library…
pauljervisheath
205
24k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
Code Review Best Practice
trishagee
65
17k
4 Signs Your Business is Dying
shpigford
182
21k
For a Future-Friendly Web
brad_frost
175
9.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Code Reviewing Like a Champion
maltzj
521
39k
Transcript
Docker ೖ NaITE #13 2016.4.27
ࣗݾհ ໊લɿ֯ాɹढ़ʢͭͷͩɹ͠ΎΜʣ ίϛϡχςΟɿNaITEɹͳͲ Twitterɿ͍ΉͯΜˏimtnd ۈઌɿ௨৴ܥۀ ۀɿιϑτΣΞ։ൃɹ5
Docker
ຊηογϣϯͷత DockerΛͳΜͱͳ͘ཧղ͢Δ DockerΛ࠷ݶ͑ΔΑ͏ʹͳΔ
Docker
Dockerʹ͍ͭͯ DockerͱɺԾԽٕज़ͷҰͭ ίϯςφͱ͍͏୯ҐͰԾԽ͢Δ͜ͱʹΑΓɺ OSͳͲʹґଘ͠ͳ͍γεςϜΛఏڙ
Dockerʹ͍ͭͯ Virtual Machine container https://www.docker.com/what-docker
DockerͷϝϦοτ VMͱҧ͍ܰྔͰ͋Γɺىಈɺऴ͕ྃߴͰ ͋Δ CIͳͲͰ͍ࣺͯͳ͕ΒΫϦʔϯͳڥͰς ετ͢Δ͜ͱ͕Ͱ͖Δ ύοέʔδΠϝʔδ͕ڞ༗Ͱ͖ɺ͙͢ʹ༻ ͢ΔΈ͕͋Δ
Docker Toolbox
Docker Toolbox Dockerʹؔ࿈͢Δπʔϧ͕ύοέʔδԽ͞Ε ͨͷ Docker Engine Docker Machine Docker Compose
Kitematic
DockerͷΠϯετʔϧํ๏ Cent OS 7 Ҏ্ yum ͰΠϯετʔϧՄೳ Ubuntu 15.04 Ҏ্
ύοέʔδΛՃͯ͠ɺapt-getͰΠϯε τʔϧՄೳ https://docs.docker.com/engine/installation/linux/ubuntulinux/
DockerͷΠϯετʔϧํ๏ ίϯςφઐ༻OS https://coreos.com/using-coreos/containers/
DockerͷΠϯετʔϧํ๏ ίϯςφઐ༻OS CoreOS Project Atomic Red Hat Enterprise Linux Atomic
Host Snappy Ubuntu Core
DockerͷΠϯετʔϧํ๏ WindowsɺMac OSͷ߹ Virtual Box Docker Toolbox ※ɹ2016/04/27ݱࡏͷϝδϟʔͳํ๏
DockerͷΠϯετʔϧํ๏ MacOSͱWindowsͷωΠςΟϒԾԽΛ༻͍ͨ Docker७ਖ਼πʔϧʮDocker for Mac/Windowsʯొɺ VirtualBoxෆཁʹ http://www.publickey1.jp/blog/16/docker_for_macwindows.html
WindowsɺMac OSͰԿߟ͑ͳ͍ͰΠϯε τʔϧ͢ΔͱɺVIrtual Box্ʹ”default”ͱ͍ ͏ԾϚγϯ͕Ͱ͖͍ͯΔ Linuxͷ߹ίϚϯυͰɺDocker༻ͷԾ ϚγϯΛ࡞͢Δ DockerͷΠϯετʔϧํ๏
Docker Machine
Docker Machine Docker ϗετΛϚωδϝϯτ͢Δπʔϧ Docker ϗετͷ࡞ Docker ϗετͷىಈ Docker ϗετͷऴྃɹɹɹͳͲ
Docker MachineίϚϯυ Docker MachineΛVirtual Box্ʹ࡞ Docker Machineͷআ $docker-machine create —driver
virtualbox vmD(ԾϚγϯ໊) $docker-machine rm vmD(ԾϚγϯ໊)
Docker MachineίϚϯυ Dockerϗετͷىಈ Dockerϗετͷऴྃ DockerϗετͷҰཡදࣔ $docker-machine start default(ԾϚγϯ໊) $docker-machine stop
default(ԾϚγϯ໊) $docker-machine ls
Docker MachineίϚϯυ DockerϗετͷIPΞυϨε֬ೝ DockerϗετͷϩάΠϯ Dockerϗετͷڥม֬ೝ $docker-machine ip default(ԾϚγϯ໊) $docker-machine ssh
default(ԾϚγϯ໊) $docker-machine env default(ԾϚγϯ໊)
DockerίϚϯυ DockerͷΠϝʔδͷऔಘ $docker pull centos:centos6 ϦϙδτϦ໊ λά
DockerίϚϯυ $docker pull centos:centos6 DockerϨδετϦʹ ެ։͞Εͨ DockerΠϝʔδ pull
DockerϨδετϦ DockerϨδετϦͱɺDockerͷΠϝʔδΛ ཧ͓ͯ͘͠ॴ ެࣜͰ༻ҙ͍ͯ͠ΔDockerϨδετϦ Docker Hub https://hub.docker.com/
DockerίϚϯυ Docker ΠϝʔδͷҰཡදࣔ Docker Πϝʔδͷআ $docker images $docker rmi centos:centos6(ϦϙδτϦ໊:λά)
DockerίϚϯυ Cent OSͷDockerΠϝʔδΛಈ͔ͯ͠ΈΔ $docker run -t -i —name centos centos:centos6
/bin/bash ίϯςφ໊Λ͚ΒΕΔ
DockerίϚϯυ Docker ίϯςφͷҰཡදࣔ Docker ίϯςφͷআ $docker ps -a $docker rm
centos6(ίϯςφ໊)
DockerίϚϯυ nginx(ΤϯδϯΤοΫε)ͷΠϝʔδऔಘ ϙʔτʹׂΓ͚ͯىಈ $docker pull nginx:latest $docker run -d -p
8080:80 —name nginx nginx:latest WebαʔόΛಈ͔ͯ͠ΈΔ
DockerίϚϯυ Docker ίϯςφͷऴྃ Docker ίϯςφͷىಈ $docker stop nginx(ίϯςφ໊) $docker start
nginx(ίϯςφ໊)
Dockerfile DockerfileͱɺDockerΠϝʔδΛ࡞͢Δ ݩͱͳΔϑΝΠϧ makeϑΝΠϧͷΑ͏ͳͰɺҰίϚϯυͰ DockerΠϝʔδ͕࡞ग़དྷΔ ؆୯ʹهड़Ͱ͖ɺݟͨཧղ͍͢͠ͷ͕ ಛ
Dockerfile Dockerfileαϯϓϧ $git clone https://github.com/imtnd/httpd.git httpd +- Dockerfile +- index.html
※ɹGit͕ͳ͍ਓϒϥβ͔ΒΞΫηε
Dockerfile httpdσΟϨΫτϦʹҠಈ $cd httpd DockerfileΛݩʹDockerΠϝʔδͷ࡞ $docker build -t httpd ./
Dockerfile ίϯςφͷىಈ $docker run -d -p 80:80 httpd(ϦϙδτϦ໊) ϒϥβͰϗετͷIPΞυϨεʹΞΫηε͠ ͯΈΔͱɺ”hello
docker”ͱݟ͑Δ
Dockerfile FROM centos:centos6 MAINTAINER imtnd RUN yum install -y httpd
ADD index.html /var/www/html/index.html EXPOSE 80/tcp CMD ["/usr/sbin/httpd","-D","FOREGROUND"]
Dockerfile FROM centos:centos6 MAINTAINER imtnd RUN yum install -y httpd
ADD index.html /var/www/html/index.html EXPOSE 80/tcp CMD ["/usr/sbin/httpd","-D","FOREGROUND"] ϕʔεͷDockerΠϝʔδ
Dockerfile FROM centos:centos6 MAINTAINER imtnd RUN yum install -y httpd
ADD index.html /var/www/html/index.html EXPOSE 80/tcp CMD ["/usr/sbin/httpd","-D","FOREGROUND"] DockerΠϝʔδ࡞ऀ
Dockerfile FROM centos:centos6 MAINTAINER imtnd RUN yum install -y httpd
ADD index.html /var/www/html/index.html EXPOSE 80/tcp CMD ["/usr/sbin/httpd","-D","FOREGROUND"] ίϚϯυͷ࣮ߦࢦࣔ
Dockerfile FROM centos:centos6 MAINTAINER imtnd RUN yum install -y httpd
ADD index.html /var/www/html/index.html EXPOSE 80/tcp CMD ["/usr/sbin/httpd","-D","FOREGROUND"] ϑΝΠϧͷՃࢦࣔ
Dockerfile FROM centos:centos6 MAINTAINER imtnd RUN yum install -y httpd
ADD index.html /var/www/html/index.html EXPOSE 80/tcp CMD ["/usr/sbin/httpd","-D","FOREGROUND"] ϙʔτ൪߸ͷొ
Dockerfile FROM centos:centos6 MAINTAINER imtnd RUN yum install -y httpd
ADD index.html /var/www/html/index.html EXPOSE 80/tcp CMD ["/usr/sbin/httpd","-D","FOREGROUND"] ίϯςφىಈ࣌ͷ ࣮ߦίϚϯυࢦࣔ
Docker Compose
Docker Compose ίϯςφαʔϏε୯ҐͰߏங͍ͯ͘͠ͱ ཧָ͕ʹͳΔʢΞϓϦɺDBͳͲʣ αʔϏεෳͷίϯςφʹΑͬͯߏங͞Ε Δ͜ͱʹͳΔͨΊҰׅͰཧ͢Δඞཁ͕͋Δ ෳͷίϯςϯΛཧग़དྷΔΈ͕ɺ Docker Compose
Docker Compose Docker ComposeɺYMLϑΝΠϧͰίϯςφΛཧ ͢Δ YMLϑΝΠϧαϯϓϧ(TestLinkͱ͍͏αʔϏε͕ಈ͘) $git clone https://github.com/imtnd/testlink_yml.git ※ɹGit͕ͳ͍ਓϒϥβ͔ΒΞΫηε
Docker Compose YMLϑΝΠϧΛݩʹαʔϏεΛىಈ ίϯςφͷঢ়ଶ֬ೝ $docker-compose up -d $docker-compose ps ԼهΞυϨεʹϒϥβ͔ΒΞΫηϧͰ͖Δ
http://xxx.xxx.xxx.xxx(ϗετͷIPΞυϨε)/testlink/ ॳظઃఆͳͲԼهαΠτΛࢀর http://qiita.com/imtnd/items/a58a707db08c3710d963
Docker Compose αʔϏεͷఀࢭ $docker-compose stop ҰίϚϯυͰɺMySQLɺTestLinkͷαʔϏε ͷίϯςφ͕ىಈͯ͠Δɻ busyboxͱ͍͏ͷɺσʔλΛӬଓԽ͢Δͨ Ίͷίϯςφ
Docker Compose Docker hubʹ͋ΔΠϝʔδΛ༻͢Δͱ໘ ͍͘͞ΠϯϑϥߏஙΛ͠ͳ͍ͰɺڥΛηοτ Ξοϓ͢Δ͜ͱ͕Ͱ͖Δɻ ڵຯΛ࣋ͬͨπʔϧΛ؆୯ʹ༻ͯ͠Έ͍ͨ࣌ ͳͲʹ࠷ద (πʔϧ໊)ɹdocker compose
ͦͷଞπʔϧ Docker Swarm Docker Registory Kitematic
ίϯςφؔ࿈αʔϏε tutum Kubernates
࠷ޙʹ Docker ·ͩ·ͩ·ͩ·ͩൃల్தͳπʔ ϧͰ͢ɻ ͜ͷεϥΠυͷใաڈͷʹͳ͍͖ͬͯ ·͢ɻ ൃల్தͰ͋Δ͕ނʹɺ࠷৽ಈΛͬͯΈ Δͱ໘ന͍ͱࢥ͍·͢ɻ
Let’s Run Container