お前のDockerイメージはまだ重い💢💢💢

0aac627116c6e2a87b9ae179500801df?s=47 stormcat24
February 05, 2016

 お前のDockerイメージはまだ重い💢💢💢

2016/02/05 JAWS-UG コンテナ支部 #4

0aac627116c6e2a87b9ae179500801df?s=128

stormcat24

February 05, 2016
Tweet

Transcript

  1. ͓લͷ%PDLFSΠϝʔδ͸ ·ͩॏ͍ 2016/02/05 JAWS-UG ίϯςφࢧ෦ #4 @stormcat24 ʙମࢷ๱཰1έλͷDockerΠϝʔδΛ໨ࢦͯ͠ʙ

  2. ‣ @stormcat24 ‣ Akinori Yamada ‣ CyberAgent, Inc ‣ Technical

    Engineer ‣ DevOps ‣ http://stormcat.hatenablog.com ‣ AmebaFRESH!
  3. "NFCB'3&4)

  4. ौ୩ఆ఺Χϝϥͱ͔

  5. ण࢘԰ϥΠϒͱ͔

  6. AmebaFRESH! is Full Dockernized Service! by EC2 Container Service

  7. ͦ͏͍΍લճ΋஻Γ·ͨ͠ https://speakerdeck.com/stormcat24/next-fresh-applications-with-amazon-ecs

  8. લճͷ࿩͸ɾɾɾ ‣ FRESH!ͷECS࢖ͬͨΞʔΩςΫνϟ ‣ Blue Green Deploymentͱ͔ ‣ docker-machineͰͷϩʔΧϧ։ൃ ‣

    DockerΠϝʔδͷݮྔ ‣ ͦͷଞDevOpsͱ͔
  9. ࠓ೔͸ݮྔͷ࿩͚ͩ͠·͢

  10. ಥવͰ͕͢

  11. ໿(#ͷ%PDLFSΠϝʔδ QVMMʹԿඵ͔͔Δʁ

  12. ଌఆ৚݅ ‣ EC2্ͷPrivate Docker Registry(V2)Λར༻ ‣ Registry͕ར༻͢ΔετϨʔδ͸S3 ‣ ಉҰϦʔδϣϯͷEC2͔ΒࢦఆͷΠϝʔδΛdocker pull͢Δ

    ‣ EC2ɺS3ڞʹap-northeast-1(Tokyo) ‣ EC2্ʹ͸ΠϝʔδͷϨΠϠʔΩϟογϡ͸ଘࡏ͠ ͳ͍΋ͷͱ͢Δ
  13. "OTXFS໿ඵ ※ΠϝʔδʹΑͬͯࠩ͸΋ͪΖΜ͋Γ·͢

  14. ࣮͸͜Ε͸͔ͳΓ޷৚݅ ‣ EC2ͱRegistry, S3͸ಉҰϦʔδϣϯͳͷͰϨΠς ϯγ௿ ‣ DockerHubʹಉΠϝʔδΛஔ͍ͨ৔߹ɺ໿75ඵ͘ Β͍ͩͬͨ

  15. ඵͳΒѱ͘ͳ͍ɾɾɾʁ

  16. ͍΍ɺݱ࣮͸ݫ͍͠

  17. ίϯςφ̍ͭͰ͸੒ཱ͠ͳ͍

  18. զʑ͸ଟ͘ͷίϯςφΛӡ༻͢Δɹ ‣ ༷ʑͳ໾ׂͷίϯϙʔωϯτͰγεςϜ͸੒ཱ ‣ ଞͷίϯςφͱڠௐͯ͠ಈ͘ ‣ td-agentͷग़൪΋ଟ͍ ‣ 1ͭͷϗετΛσϓϩΠ͢Δͷʹɺෳ਺ͷDockerί ϯςφΛpull͢Δඞཁ͕͋Δ

  19. ίϯςφʹඵɺ஗͍

  20. %PDLFSΠϝʔδ͕େ͖͍ͱ ‣ ΠϝʔδͷϏϧυɺCI࣌ؒ↑ ‣ Πϝʔδͷμ΢ϯϩʔυ࣌ؒ↑ ‣ ΠϝʔδͷΞοϓϩʔυ࣌ؒ↑ ‣ ੜ࢈ੑ↓ ‣

    Twitter͢Δ࣌ؒ↑
  21. ӡ༻ʹٴ΅͢Өڹ ‣ σϓϩΠ࣌ؒ↑ ‣ “ࣺͯΔΠϯϑϥӡ༻”ͷ৔߹ɺΠϝʔδͷϨΠϠʔ Ωϟογϡʹ͸͋·ΓཔΕͳ͍ʢϑϧμ΢ϯϩʔυ ͕ଟ͍ʣ ‣ EC2ͷAutoScalingͰ௥Ճ͞ΕͨΠϯελϯε͕ αʔϏεΠϯ͢Δ·Ͱͷ࣌ؒ↑

  22. ॏ͍%PDLFSΠϝʔδ ྑ͍͜ͱແ͠

  23. ͚ܰΕ͹͍ܰ΄Ͳ Ձ஋͕͋Δ

  24. ΑΖ͍͠ɺͰ͸ݮྔͩ

  25. Πϝʔδݮྔϝιου ‣ ΠϝʔδͷϨΠϠʔ਺ΛݮΒ͢ ‣ ࢈ۀഇغ෺Λద੾ʹॲཧ͢Δ ‣ ϘϦϡʔϜϚ΢ϯτΛ׆༻͢Δ ‣ ͍ܰϕʔεΠϝʔδͷબఆ ‣

    ϘτϧωοΫʢࢷ๱͕͍ͭͯΔՕॴʣΛಛఆ͢Δ ‣ ΞϓϦέʔγϣϯΛখ͘͢͞Δ
  26. ϨΠϠʔ਺ΛݮΒ͢ ‣ DockerΠϝʔδ͸εςʔδຖʹϨΠϠʔΛੜ੒͢ ΔʢϨΠϠʔߏ଄ʣ ‣ ϨΠϠʔࣗ਎΋ΠϝʔδͳͷͰɺϨΠϠʔ਺ΛݮΒ ͤ͹αΠζ΋ݮΔ

  27. 36/ΛνΣʔϯ͢Δ 36/FDIPEFCIUUQQQBMBVODIQBEOFUOHJOYTUBCMFVCVOUVUSVTUZNBJOa FUDBQUTPVSDFTMJTUEOHJOYTUBCMFMJTUa BQULFZBEWLFZTFSWFSLFZTFSWFSVCVOUVDPNSFDWLFZT$&&$a BQUHFUVQEBUFZa BQUHFUJOTUBMMZOHJOYFYUSBTa BQUHFUJOTUBMMZPQFOTTMa BQUHFUJOTUBMMZHFPJQEBUBCBTFa

  28. ࢈ۀഇغ෺Λద੾ʹॲཧ͢Δ ‣ ࢈ۀഇغ෺ʹdocker build࣌ʹੜͨ͡ɺΞϓϦέʔ γϣϯ࣮ߦʹ͸ෆཁͳπʔϧ΍ϑΝΠϧ ‣ yum΍apt-getͷΰϛ ‣ Ϗϧυʹ࢖༻ͨ͠ιʔε ‣

    gitͰ͢Β࢈ۀഇغ෺ ‣ ੒Ռ෺͚ͩ࢒͢͜ͱΛҙࣝ͢Δ
  29. ϘϦϡʔϜϚ΢ϯτΛ׆༻͢Δ ‣ ϗετʹඞཁͳσΟϨΫτϦΛ഑ஔ͠ɺίϯςφʹ Ϛ΢ϯτ͢Δ͜ͱͰΠϝʔδͷαΠζΛ࡟ݮ͢Δ ‣ ࡟ݮςΫχοΫͱͯ͠͸༗ޮ ‣ ϗετʹґଘ͢ΔΑ͏ʹͳΔͨΊɺϙʔλϏϦςΟ ͸མͪΔ

  30. %PDLFS)VC

  31. %PDLFS)VC ‣ DockerΠϝʔδͷGitHubΈ͍ͨͳ΋Μ ‣ ཉ͍͠΋ͷ͸େ఍खʹೖΔ ‣ ༷ʑͳϓϩμΫτͷެࣜΠϝʔδ͕ଟ͘ϗετ͞Ε ͍ͯΔ ‣ ීஈԿؾͳ͘͢Δdocker

    pullͰ͸ɺ͔͜͜ΒΠϝʔ δΛμ΢ϯϩʔυ͢Δ
  32. ΠϝʔδͷαΠζΛ֬ೝͰ͖Δ

  33. ެࣜΠϝʔδΛ࢖͏΂͖͔ʁ ‣ όʔδϣϯ΋๛෋Ͱ඼࣭తʹ͸ܭࢉͰ͖Δ͕ɾɾɾ ‣ ΠϝʔδͷαΠζ͸ඞͣ͠΋࠷దԽ͞Ε͍ͯΔͱ͸ ݶΒͳ͍ͷͰαΠζ֬ೝॏཁ ‣ ϝδϟʔͲ͜Ζ͸ubuntu΍debianϕʔε͕ଟ͍ ‣ Dockerfileͷϊ΢ϋ΢͚ͩ௖͍ͯɺϕʔεΠϝʔδ

    ͚ͩม͑Δͷ΋બ୒ࢶ
  34. TDSBUDI ‣ ͓ͦΒ͘ݱଘ࠷খͷDockerΠϝʔδ ‣ sh΋ls΋ͳ͍ ‣ ࣮͸amazon/amazon-ecs-agent(9MB)ͷϕʔε ‣ ඞཁͳ΋ͷ͸શ෦ηϧϑαʔϏε

  35. #VTZCPY ‣ ௒ܰྔͰΠϝʔδ͸600KBʙ2MB ‣ ݩ͸૊ΈࠐΈܥLinuxͷσϑΝΫτͩͬͨ ‣ γΣϧ͸ash ‣ ѻ͍͸͔ͳΓ೉͍͠ʢதͰϏϧυ͠Α͏ͱࢥ͏ͳʣ ‣

    goͷ࣮ߦϑΝΠϧΛCOPY͘Β͍͕ؔͷࢁ
  36. "MQJOF-JOVY ‣ Πϝʔδ͸2MB ‣ ࣮͸Busyboxϕʔε ‣ APKͱ͍͏ύοέʔδ؅ཧγεςϜ͕͋ΔͷͰɺ BusyboxΑΓѻ͍΍͍͢

  37. "1,Ͱ͕Μ͹ͬͯΔྫ 36/BQLVQEBUFBEEPQFOTTMEFWQDSFEFW[MJCEFWXHFUCVJMECBTFa NLEJSQUNQTSDa DEUNQTSDa XHFUIUUQOHJOYPSHEPXOMPBEOHJOYUBSH[a UBS[YWGOHJOYUBSH[UBSH[a DEUNQTSDOHJOYUBSH[a DPOpHVSFa XJUIIUUQ@TTM@NPEVMFa XJUIIUUQ@H[JQ@TUBUJD@NPEVMFa

    QSFpYFUDOHJOYa IUUQMPHQBUIWBSMPHOHJOYBDDFTTMPHa FSSPSMPHQBUIWBSMPHOHJOYFSSPSMPHa TCJOQBUIVTSMPDBMTCJOOHJOYa NBLFa NBLFJOTUBMMa BQLEFMCVJMECBTFa SNSGUNQTSDa SNSGWBSDBDIFBQL
  38. "MQJOF೿ੜओཁΠϝʔδ ‣ anapsix/alpine-javaʢ໿50MBʣ ‣ cwt114/alpine-nodeʢ໿15MBʣ ‣ frolvlad/alpine-rubyʢ໿10MBʣ ‣ frolvlad/alpine-goʢ໿50MBʣ ‣

    ಉ͡Α͏ͳͷΰϩΰϩస͕ͬͯΔ
  39. ࠓͷͱ͜Ζͷ"MQJOFॴײ ‣ ཪͰຊ൪౤ೖͷػӡΛ࢕ͬͯΔʢλΠϛϯά࣍ୈʣ ‣ nginx͕150MB→20MB͘Β͍ ‣ ฏۉ80%͘Β͍ͷ࡟ݮ͕ظ଴Ͱ͖Δ ‣ Web/APIͷECS Taskʢίϯςφ4छʣͰ200-

    300MB͘Β͍ɺ1෼͘Β͍Ͱpull+runͰ͖Δ
  40. ܰ͞ͱͷτϨʔυΦϑ ‣ Dockerfile࡞Γ͕৬ਓܳʹͳΓ͕ͪ ‣ AlpineͷϦϙδτϦʹ͋Δύοέʔδͷόʔδϣϯ ͕ͦΕ΄Ͳ৽઱Ͱ͸ͳ͍ ‣ ࠷৽൛ͷϛυϧ΢ΣΞΛೖΕΔͷʹɺιʔείϯύ Πϧ͔Β࢝ΊͨΓ͢Δඞཁ͕͋Δ

  41. *NBHF-BZFSJP ‣ https://imagelayers.io ‣ DockerΠϝʔδͷϨΠϠʔΛՄࢹԽͯ͘͠ΕΔ αʔϏε ‣ DockerHub࿈ܞ ‣ ଠ͍ՕॴΛҰൃͰ਍அͯ͘͠ΕΔ

  42. None
  43. %PDLFS)VCͱ࿈ܞͰ͖Δ

  44. ͲͷϨΠϠʔʹ ࢷ๱͕͍ͭͯΔ͔ Ұ໨ྎવ

  45. ಠࣗϨδετϦͰ࢖͑Δʁ ‣ GitHubͱDockerHubʹެ։͞ΕͯΔ ‣ centurylink/imagelayers-api ‣ centurylink/imagelayers-ui ‣ ϨδετϦΛࠩ͠ସ͑ΒΕΔ࢓૊Έʹͳͬͯͳ͍ ‣

    Registry(V1)લఏͷ໛༷ ‣ forkͯͪ͠ΐͬͱؤுΕ͹ɾɾɾ
  46. ΞϓϦέʔγϣϯΛখ͘͢͞Δ ‣ ίϯςφ࣌୅Ͱ͸αΠζͷখ͞͞΋໰ΘΕΔ ‣ Dockerܳਓʹ͸֤ݴޠͷϏϧυπʔϧͷ஌ࣝ΋໰ ΘΕΔ ‣ Node: npm ‣

    Java/Scala: Maven, Gradle, sbt ‣ Go: godep, glide
  47. ΞϓϦέʔγϣϯϨϕϧͰͷݮྔ ‣ ෆཁϞδϡʔϧͷ࡟আ ‣ ෆཁͳґଘϥΠϒϥϦͷ࡟আɺϥΠϒϥϦͷείʔ ϓͷݟ௚͠ ‣ ↑ͷͨΊͷϦϑΝΫλϦϯά ‣ ੩తϑΝΠϧ౳ɺ֎෦ʹग़ͤͦ͏ͳϦιʔεͷબผ

  48. %PDLFS༗ࣝऀ͚ͩͰ͸੒ޭ͠ͳ͍ ‣ ίϯςφϕʔεͰӡ༻͢Δ͚ͩͰ͋Ε͹ɺDocker ༗ࣝऀ͚ͩͰͳΜͱ͔ͳΔ͕ɾɾɾ ‣ ReactͷαʔόαΠυϨϯμϦϯά౳ʑɺϑϩϯτ دΓͷྖҬͰͷཧղΛಘΔ͜ͱ͕ॏཁ ‣ ߴ͍ϨϕϧͰͷӡ༻ʹ͸ɺDocker༗ࣝऀʹٻΊΒ ΕΔٕज़ྖҬ͸࣮͸޿͍

  49. ·ͱΊ ‣ ॏ͗͢ΔΠϝʔδ͸ӡ༻ͷোนʹͳΔ ‣ ϙʔλϏϦςΟͱɺܰ͞Λ݉Ͷඋ͑ͯͦ͜ྑ͍ DockerΠϝʔδ ‣ ެࣜΠϝʔδա৴͢Δͳ ‣ Alpine(ɾ㱼ɾ)ŘŘŮ!!

    ‣ ΞϓϦͷστοΫε΋๨Εͣʹ
  50. ໨ࢦͤɺମࢷ๱཰έλ

  51. Thank you.