Slide 1

Slide 1 text

Docker ೖ໳ NaITE #13 2016.4.27

Slide 2

Slide 2 text

ࣗݾ঺հ ໊લɿ֯ాɹढ़ʢͭͷͩɹ͠ΎΜʣ ίϛϡχςΟɿNaITEɹͳͲ Twitterɿ͍ΉͯΜˏimtnd ۈ຿ઌɿ௨৴ܥ੡଄ۀ ۀ຿ɿιϑτ΢ΣΞ։ൃɹ5೥໨

Slide 3

Slide 3 text

Docker

Slide 4

Slide 4 text

ຊηογϣϯͷ໨త DockerΛͳΜͱͳ͘ཧղ͢Δ DockerΛ࠷௿ݶ࢖͑ΔΑ͏ʹͳΔ

Slide 5

Slide 5 text

Docker

Slide 6

Slide 6 text

Dockerʹ͍ͭͯ Dockerͱ͸ɺԾ૝Խٕज़ͷҰͭ ίϯςφͱ͍͏୯ҐͰԾ૝Խ͢Δ͜ͱʹΑΓɺ OSͳͲʹґଘ͠ͳ͍γεςϜΛఏڙ

Slide 7

Slide 7 text

Dockerʹ͍ͭͯ Virtual Machine container https://www.docker.com/what-docker

Slide 8

Slide 8 text

DockerͷϝϦοτ VMͱҧ͍ܰྔͰ͋Γɺىಈɺऴ͕ྃߴ଎Ͱ ͋Δ CIͳͲͰ࢖͍ࣺͯͳ͕ΒΫϦʔϯͳ؀ڥͰς ετ͢Δ͜ͱ͕Ͱ͖Δ ύοέʔδΠϝʔδ͕ڞ༗Ͱ͖ɺ͙͢ʹ࢖༻ ͢Δ࢓૊Έ͕͋Δ

Slide 9

Slide 9 text

Docker Toolbox

Slide 10

Slide 10 text

Docker Toolbox Dockerʹؔ࿈͢Δπʔϧ͕ύοέʔδԽ͞Ε ͨ΋ͷ Docker Engine Docker Machine Docker Compose Kitematic

Slide 11

Slide 11 text

DockerͷΠϯετʔϧํ๏ Cent OS 7 Ҏ্ yum ͰΠϯετʔϧՄೳ Ubuntu 15.04 Ҏ্ ύοέʔδΛ௥Ճͯ͠ɺapt-getͰΠϯε τʔϧՄೳ https://docs.docker.com/engine/installation/linux/ubuntulinux/

Slide 12

Slide 12 text

DockerͷΠϯετʔϧํ๏ ίϯςφઐ༻OS https://coreos.com/using-coreos/containers/

Slide 13

Slide 13 text

DockerͷΠϯετʔϧํ๏ ίϯςφઐ༻OS CoreOS Project Atomic Red Hat Enterprise Linux Atomic Host Snappy Ubuntu Core

Slide 14

Slide 14 text

DockerͷΠϯετʔϧํ๏ WindowsɺMac OSͷ৔߹ Virtual Box Docker Toolbox ※ɹ2016/04/27ݱࡏͷϝδϟʔͳํ๏

Slide 15

Slide 15 text

DockerͷΠϯετʔϧํ๏ MacOSͱWindowsͷωΠςΟϒԾ૝ԽΛ༻͍ͨ Docker७ਖ਼πʔϧʮDocker for Mac/Windowsʯొ৔ɺ VirtualBox͸ෆཁʹ http://www.publickey1.jp/blog/16/docker_for_macwindows.html

Slide 16

Slide 16 text

WindowsɺMac OSͰԿ΋ߟ͑ͳ͍ͰΠϯε τʔϧ͢ΔͱɺVIrtual Box্ʹ”default”ͱ͍ ͏Ծ૝Ϛγϯ͕Ͱ͖͍ͯΔ Linuxͷ৔߹͸ίϚϯυͰɺDocker༻ͷԾ૝ ϚγϯΛ࡞੒͢Δ DockerͷΠϯετʔϧํ๏

Slide 17

Slide 17 text

Docker Machine

Slide 18

Slide 18 text

Docker Machine Docker ϗετΛϚωδϝϯτ͢Δπʔϧ Docker ϗετͷ࡞੒ Docker ϗετͷىಈ Docker ϗετͷऴྃɹɹɹͳͲ

Slide 19

Slide 19 text

Docker MachineίϚϯυ Docker MachineΛVirtual Box্ʹ࡞੒ Docker Machineͷ࡟আ $docker-machine create —driver virtualbox vmD(Ծ૝Ϛγϯ໊) $docker-machine rm vmD(Ծ૝Ϛγϯ໊)

Slide 20

Slide 20 text

Docker MachineίϚϯυ Dockerϗετͷىಈ Dockerϗετͷऴྃ DockerϗετͷҰཡදࣔ $docker-machine start default(Ծ૝Ϛγϯ໊) $docker-machine stop default(Ծ૝Ϛγϯ໊) $docker-machine ls

Slide 21

Slide 21 text

Docker MachineίϚϯυ DockerϗετͷIPΞυϨε֬ೝ Dockerϗετ΁ͷϩάΠϯ Dockerϗετͷ؀ڥม਺֬ೝ $docker-machine ip default(Ծ૝Ϛγϯ໊) $docker-machine ssh default(Ծ૝Ϛγϯ໊) $docker-machine env default(Ծ૝Ϛγϯ໊)

Slide 22

Slide 22 text

DockerίϚϯυ DockerͷΠϝʔδͷऔಘ $docker pull centos:centos6 ϦϙδτϦ໊ λά

Slide 23

Slide 23 text

DockerίϚϯυ $docker pull centos:centos6 DockerϨδετϦʹ ެ։͞Εͨ DockerΠϝʔδ pull

Slide 24

Slide 24 text

DockerϨδετϦ DockerϨδετϦͱ͸ɺDockerͷΠϝʔδΛ ؅ཧ͓ͯ͘͠৔ॴ ެࣜͰ༻ҙ͍ͯ͠ΔDockerϨδετϦ͸ Docker Hub https://hub.docker.com/

Slide 25

Slide 25 text

DockerίϚϯυ Docker ΠϝʔδͷҰཡදࣔ Docker Πϝʔδͷ࡟আ $docker images $docker rmi centos:centos6(ϦϙδτϦ໊:λά)

Slide 26

Slide 26 text

DockerίϚϯυ Cent OSͷDockerΠϝʔδΛಈ͔ͯ͠ΈΔ $docker run -t -i —name centos centos:centos6 /bin/bash ίϯςφ໊Λ෇͚ΒΕΔ

Slide 27

Slide 27 text

DockerίϚϯυ Docker ίϯςφͷҰཡදࣔ Docker ίϯςφͷ࡟আ $docker ps -a $docker rm centos6(ίϯςφ໊)

Slide 28

Slide 28 text

DockerίϚϯυ nginx(ΤϯδϯΤοΫε)ͷΠϝʔδऔಘ ϙʔτʹׂΓ෇͚ͯىಈ $docker pull nginx:latest $docker run -d -p 8080:80 —name nginx nginx:latest WebαʔόΛಈ͔ͯ͠ΈΔ

Slide 29

Slide 29 text

DockerίϚϯυ Docker ίϯςφͷऴྃ Docker ίϯςφͷىಈ $docker stop nginx(ίϯςφ໊) $docker start nginx(ίϯςφ໊)

Slide 30

Slide 30 text

Dockerfile Dockerfileͱ͸ɺDockerΠϝʔδΛ࡞੒͢Δ ݩͱͳΔϑΝΠϧ makeϑΝΠϧͷΑ͏ͳ෺ͰɺҰίϚϯυͰ DockerΠϝʔδ͕࡞੒ग़དྷΔ ؆୯ʹهड़Ͱ͖ɺݟͨ໨΋ཧղ͠΍͍͢ͷ͕ ಛ௃

Slide 31

Slide 31 text

Dockerfile Dockerfileαϯϓϧ $git clone https://github.com/imtnd/httpd.git httpd +- Dockerfile +- index.html ※ɹGit͕ͳ͍ਓ͸ϒϥ΢β͔Β௚઀ΞΫηε

Slide 32

Slide 32 text

Dockerfile httpdσΟϨΫτϦʹҠಈ $cd httpd DockerfileΛݩʹDockerΠϝʔδͷ࡞੒ $docker build -t httpd ./

Slide 33

Slide 33 text

Dockerfile ίϯςφͷىಈ $docker run -d -p 80:80 httpd(ϦϙδτϦ໊) ϒϥ΢βͰϗετͷIPΞυϨεʹΞΫηε͠ ͯΈΔͱɺ”hello docker”ͱݟ͑Δ

Slide 34

Slide 34 text

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"]

Slide 35

Slide 35 text

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Πϝʔδ

Slide 36

Slide 36 text

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Πϝʔδ࡞੒ऀ

Slide 37

Slide 37 text

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"] ίϚϯυͷ࣮ߦࢦࣔ

Slide 38

Slide 38 text

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"] ϑΝΠϧͷ௥Ճࢦࣔ

Slide 39

Slide 39 text

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"] ϙʔτ൪߸ͷొ࿥

Slide 40

Slide 40 text

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"] ίϯςφىಈ࣌ͷ ࣮ߦίϚϯυࢦࣔ

Slide 41

Slide 41 text

Docker Compose

Slide 42

Slide 42 text

Docker Compose ίϯςφ͸αʔϏε୯ҐͰߏங͍ͯ͘͠ͱ؅ ཧָ͕ʹͳΔʢΞϓϦɺDBͳͲʣ αʔϏε͸ෳ਺ͷίϯςφʹΑͬͯߏங͞Ε Δ͜ͱʹͳΔͨΊҰׅͰ؅ཧ͢Δඞཁ͕͋Δ ෳ਺ͷίϯςϯΛ؅ཧग़དྷΔ࢓૊Έ͕ɺ Docker Compose

Slide 43

Slide 43 text

Docker Compose Docker Compose͸ɺYMLϑΝΠϧͰίϯςφΛ؅ཧ ͢Δ YMLϑΝΠϧαϯϓϧ(TestLinkͱ͍͏αʔϏε͕ಈ͘) $git clone https://github.com/imtnd/testlink_yml.git ※ɹGit͕ͳ͍ਓ͸ϒϥ΢β͔Β௚઀ΞΫηε

Slide 44

Slide 44 text

Docker Compose YMLϑΝΠϧΛݩʹαʔϏεΛىಈ ίϯςφͷঢ়ଶ֬ೝ $docker-compose up -d $docker-compose ps ԼهΞυϨεʹϒϥ΢β͔ΒΞΫηϧͰ͖Δ http://xxx.xxx.xxx.xxx(ϗετͷIPΞυϨε)/testlink/ ॳظઃఆͳͲ͸ԼهαΠτΛࢀর http://qiita.com/imtnd/items/a58a707db08c3710d963

Slide 45

Slide 45 text

Docker Compose αʔϏεͷఀࢭ $docker-compose stop ҰίϚϯυͰɺMySQLɺTestLinkͷαʔϏε ͷίϯςφ͕ىಈͯ͠Δɻ busyboxͱ͍͏ͷ͸ɺσʔλΛӬଓԽ͢Δͨ Ίͷίϯςφ

Slide 46

Slide 46 text

Docker Compose Docker hubʹ͋ΔΠϝʔδΛ࢖༻͢Δͱ໘౗ ͍͘͞ΠϯϑϥߏஙΛ͠ͳ͍Ͱɺ؀ڥΛηοτ Ξοϓ͢Δ͜ͱ͕Ͱ͖Δɻ ڵຯΛ࣋ͬͨπʔϧΛ؆୯ʹ࢖༻ͯ͠Έ͍ͨ࣌ ͳͲʹ࠷ద (πʔϧ໊)ɹdocker compose

Slide 47

Slide 47 text

ͦͷଞπʔϧ Docker Swarm Docker Registory Kitematic

Slide 48

Slide 48 text

ίϯςφؔ࿈αʔϏε tutum Kubernates

Slide 49

Slide 49 text

࠷ޙʹ Docker ͸·ͩ·ͩ·ͩ·ͩൃల్தͳπʔ ϧͰ͢ɻ ͜ͷεϥΠυͷ৘ใ΋աڈͷ෺ʹͳ͍͖ͬͯ ·͢ɻ ൃల్தͰ͋Δ͕ނʹɺ࠷৽ಈ޲Λ௥ͬͯΈ Δͱ໘ന͍ͱࢥ͍·͢ɻ

Slide 50

Slide 50 text

Let’s Run Container