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
4k
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
マイクロサービスにおける容易なトランザクション管理に向けて
scalar
0
140
サーバーなしでWordPress運用、できますよ。
sogaoh
PRO
0
100
NilAway による静的解析で「10 億ドル」を節約する #kyotogo / Kyoto Go 56th
ytaka23
3
380
Google Cloud で始める Cloud Run 〜AWSとの比較と実例デモで解説〜
risatube
PRO
0
110
スタートアップで取り組んでいるAzureとMicrosoft 365のセキュリティ対策/How to Improve Azure and Microsoft 365 Security at Startup
yuj1osm
0
230
社外コミュニティで学び社内に活かす共に学ぶプロジェクトの実践/backlogworld2024
nishiuma
0
270
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
150
ガバメントクラウドのセキュリティ対策事例について
fujisawaryohei
0
560
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
190
レンジャーシステムズ | 会社紹介(採用ピッチ)
rssytems
0
180
あの日俺達が夢見たサーバレスアーキテクチャ/the-serverless-architecture-we-dreamed-of
tomoki10
0
470
ハイテク休憩
sat
PRO
2
170
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
Facilitating Awesome Meetings
lara
50
6.1k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
A better future with KSS
kneath
238
17k
Making Projects Easy
brettharned
116
5.9k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Speed Design
sergeychernyshev
25
670
How to Ace a Technical Interview
jacobian
276
23k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
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