Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Docker ハンズオン 基礎編1 / Docker Handson Basic 1

takasp
August 17, 2018
170

Docker ハンズオン 基礎編1 / Docker Handson Basic 1

takasp

August 17, 2018
Tweet

Transcript

  1. Ϋϥ΢υΞʔΩςΫνϟ • SaaS
 ϒϥ΢βͳͲΛ௨ͯ͠ΞϓϦ͕ར༻Ͱ͖ɺϦιʔεΛҙࣝ͢Δඞཁ͕ͳ͍ɻ • FaaS
 ؔ਺୯ҐͷίʔυΛσϓϩΠ͢Δ͚ͩͰɺϋʔυ΢ΣΞ΍ OS Λҙࣝ͢Δඞཁ͕ͳ͍ɻ
 ؔ਺ʹ͸ඞཁͳϦΫΤετͷΈ͕౉͞Εɺ࣮ߦͨ݁͠Ռ͕Ϩεϙϯε͞ΕΔɻ

    • PaaS
 Ϋϥ΢υࣄۀऀ͕༻ҙͨ͠ɺݴޠɾϥΠϒϥϦɾπʔϧΛར༻ͯ͠։ൃ͕Ͱ͖ɺ
 σϓϩΠ΍࣮ߦ؀ڥͷઃఆมߋ͕Ͱ͖Δɻ • IaaS
 Ծ૝αʔόʔ΍ετϨʔδɺωοτϫʔΫͳͲͷجຊతͳϦιʔεͷ࡞੒ɺར༻͕Ͱ͖ɺ ͦͷ؀ڥͰσϓϩΠɾ࣮ߦ͕Ͱ͖Δɻ
  2. Ծ૝Խͱίϯςφ ίϯςφ Ծ૝Խ ϋʔυ΢ΣΞ ϋΠύʔόΠβʔ Ծ૝؀ڥ ϛυϧ΢ΣΞ ΞϓϦ ήετ04 Ծ૝؀ڥ

    ϛυϧ΢ΣΞ ΞϓϦ ήετ04 ϋʔυ΢ΣΞ ϗετ04 ίϯςφϥϯλΠϜ ίϯςφ ϛυϧ΢ΣΞ ΞϓϦ ίϯςφ ϛυϧ΢ΣΞ ΞϓϦ
  3. Docker ͱ͸ • Docker ࣾʢچ dotCloud ࣾʣ͕։ൃͨ͠ OSSɻ • ίϯςφٕज़Λ࢖ͬͨΞϓϦͷ࣮ߦ؀ڥΛ


    ߏஙɾӡ༻͢ΔͨΊͷϓϥοτϑΥʔϜɻ • ΞϓϦʹඞཁͳϑΝΠϧΛίϯςφͱͯ͠·ͱΊɺ Πϝʔδͱͯ͠ڞ༗͢Δɻ • ϙʔλϏϦςΟ͕͋Γɺૉૣ࣮͘ߦͰ͖Δɻ
  4. Docker ϨδετϦ • Docker ΠϝʔδΛެ։ɾڞ༗͢ΔϨδετϦɻ • ެࣜͱͯ͠ Docker Hub ͕ެ։͞Ε͍ͯΔɻ

    • ࣗલͰϨδετϦΛཱͯΔ͜ͱ΋Մೳɻ • جຊతʹ͸ Docker Hub ʹެ։͞Ε͍ͯΔ
 ΠϝʔδΛݩʹ࡞੒͢Δɻ
  5. ωοτϫʔΫ • αʔόʔͷ NIC ͕ docker0 ͱ͍͏Ծ૝ϒϦοδʹ
 ઀ଓ͞ΕΔɻ • 172.17.0.0/16

    ͷαϒωοτϚεΫΛ࣋ͭ
 ϓϥΠϕʔτ IP ͕ίϯςφͷ eth0 ʹׂΓ౰ͯΒΕΔɻ • ίϯςφͷ eth0 ͸ɺϗετ OS ʹ࡞੒͞Εͨ
 Ծ૝NICʢvethxxxxxxʣͱϖΞͰׂΓ౰ͯΒΕΔɻ
  6. nginx Λಈ͔ͯ͠ΈΑ͏ • nginx ͷΠϝʔδ͔Β nginx Λىಈ͢Δɻ
 nginx ͱ͍͏ΠϝʔδΛ࢖ͬͯɺweb ͱ͍͏


    ίϯςφ໊Ͱ 80 ϙʔτͰͷΞΫηεΛڐՄ͍ͯ͠Δɻ
 
 
 
 EPDLFSDPOUBJOFSSVOOBNFXFCEQOHJOY Φϓγϣϯ OBNFίϯςφͷ໊લΛࢦఆ͢Δɻ EEFUBDIίϯςφΛόοΫάϥ΢ϯυͰ࣮ߦ͢Δɻ QQVCMJTIϗετ04ͱίϯςφͷϙʔτΛϚοϐϯά͢Δɻ
  7. Docker ίϚϯυ • docker image pull • docker image ls

    • docker image rm • docker image prune • docker container run • docker container create • docker container logs • docker container ls • docker container start • docker container stop • docker container rm • docker container attach • docker container prune • docker container exec • docker container cp • docker network ls • docker network create • docker network connect • docker network disconnect • docker network rm • docker system prune
  8. ίϯςφͷϥΠϑαΠΫϧ %PDLFSίϯςφ εφοϓ γϣοτ ࡞੒ %PDLFSίϯςφ εφοϓ γϣοτ ϓϩηε ىಈ

    %PDLFSίϯςφ εφοϓ γϣοτ ఀࢭ %PDLFSίϯςφ εφοϓ γϣοτ ࡟আ docker container create ίϯςφ࡞੒ docker container run ίϯςφ࡞੒ɾىಈ docker container stop ίϯςφఀࢭ Docker Πϝʔδ docker container start ίϯςφىಈ docker container rm ίϯςφ࡟আ docker container start ίϯςφىಈ
  9. Քಇίϯςφ΁ͷ઀ଓ • Քಇ͍ͯ͠Δίϯςφʹ઀ଓ͢Δɻ • ൈ͚Δʹ͸ Ctrl + p, Ctrl +

    q Λೖྗ͢Δɻ EPDLFSDPOUBJOFSBUUBDI<Φϓγϣϯ>ίϯςφ໊ TBNQMFίϯςφʹ઀ଓ͢Δྫ EPDLFSDPOUBJOFSBUUBDITBNQMF
  10. ͓୊ • ubuntu:18.04 ͱ mysql:5.7 ΛϕʔεΠϝʔδʹͨ͠ίϯςφΛ
 ىಈ͢Δɻ • ubuntu ίϯςφʹ͸ɺapt-get

    Ͱ mysql-clientΛ
 Πϯετʔϧ͢Δɻ • ωοτϫʔΫΛ৽ن࡞੒ͯͦ͠ΕͧΕͷίϯςφͰ
 ಉ͡ωοτϫʔΫʹ઀ଓ͢Δɻ • ubuntu ίϯςφ͔Β mysql ίϚϯυΛ࢖༻ͯ͠
 mysql ίϯςφͷ MySQL ʹ઀ଓ͢Δɻ
  11. ubuntu ίϯςφʹ
 mysql-client ΛΠϯετʔϧ͢Δ • ubuntu ίϯςφʹΞλον͢Δɻ • ubuntu ίϯςφʹ

    mysql-client ΛΠϯετʔϧ
 ͯ͠ɺubuntu ίϯςφ͔Βൈ͚͓ͯ͘ɻ EPDLFSDPOUBJOFSBUUBDINZTRMDMJ BQUHFUVQEBUFBQUHFUJOTUBMMZNZTRMDMJFOU $USM Q $USM R
  12. mysql ίϯςφΛىಈͯ͠
 ࡞੒ͨ͠ωοτϫʔΫʹ઀ଓ͢Δ • mysql ίϯςφΛىಈͯ͠ɺ
 ىಈ࣌ʹ࡞੒ͨ͠ωοτϫʔΫΛࢦఆ͢Δɻ • MYSQL_ALLOW_EMPTY_PASSWORD ͱ͍͏

    ؀ڥม਺͕ඞཁͳͷͰ yes Λࢦఆ͍ͯ͠Δɻ EPDLFSDPOUBJOFSSVOEOBNFNZTRMOFUNZOFUa F.:42-@"--08@&.15:@1"44803%ZFTNZTRM
  13. ubuntu ίϯςφ͔Β
 mysql ίϯςφʹ઀ଓ͢Δ • ubuntu ίϯςφʹΞλον͢Δɻ • ubuntu ίϯςφ͔Β

    mysql ίϚϯυΛ࢖༻͠ ͯ mysql ίϯςφͷ MySQL ʹ઀ଓ͢Δɻ EPDLFSDPOUBJOFSBUUBDINZTRMDMJ ˌNZTRMINZTRM
  14. No

  15. ·ͱΊ • Docker पลΛऔΓר͘എܠ͕͋Δɻ • Docker ͷ֓೦Λ཈͑ͨɻ • ͋Δఔ౓ Docker

    ίϚϯυʹ৮Εͨɻ • Docker Λ֮͑ͨͱͯ͠΋ Linux ΍
 ωοτϫʔΫ౳ͷ஌ࣝ͸ඞཁɻ
  16. ࢀߟจݙ • DevOpsಋೖࢦೆ Infrastructure as CodeͰνʔϜ։ൃɾαʔϏεӡ༻Λޮ཰Խ͢Δ • ϓϩάϥϚͷͨΊͷDockerڭՊॻ ୈ2൛ Πϯϑϥͷجૅ஌ࣝ&ίʔυʹΑΔ؀ڥߏஙͷࣗ

    ಈԽ • ίϯςφɾϕʔεɾΦʔέετϨʔγϣϯ Docker/KubernetesͰ࡞ΔΫϥ΢υ࣌୅ͷγε ςϜج൫ • https://docs.docker.com/ • http://blogs.itmedia.co.jp/narisako/2014/07/post-047f.html • https://www.slideshare.net/zembutsu/introduction-to-docker-management-and- operations-basic • https://knowledge.sakura.ad.jp/15940/