Docker-Compose & BuildKit

6247c099ad62bf727a4f9df10b6c6f23?s=47 orisano
September 05, 2019

Docker-Compose & BuildKit

6247c099ad62bf727a4f9df10b6c6f23?s=128

orisano

September 05, 2019
Tweet

Transcript

  1. Docker Compose & BuildKit Docker Meetup Tokyo #32 #DockerTokyo @orisano

  2. docker-compose ࢖͍ͬͯΔਓ

  3. ศརͰ͢ΑͶ

  4. ෳ਺ͷίϯςφΠϝʔδΛ ؆୯ʹ࢖͑Δ

  5. ͳΜͳΒ ίϯςφҰͭͰ΋ docker-compose࢖͏

  6. ࣮ߦ࣌ͷύϥϝʔλΛ ϑΝΠϧʹهड़Ͱ͖Δ

  7. up —buildͰ buildͱrun͕ಉ࣌ͰͰ͖Δ

  8. ࠷ߴ

  9. ͱ͜ΖͰ

  10. docker-compose build ࢖͍ͬͯΔਓ͍·͔͢ʁ

  11. ͍ͳ͍Ͱ͢ΑͶ… (ҙ֎ͱ͍Δͷ͔)

  12. docker-compose up —build ࢖ͬͪΌ͍·͢ΑͶ

  13. Ͱ΋ docker-composeͷbuild ॏ͘ͳ͍Ͱ͔͢?

  14. docker build͕஗͍ͱ ΠϥΠϥ͠·ͤΜ͔?

  15. BuildKit࢖͍ͨ͘ͳ͍Ͱ͔͢?

  16. docker-compose Ͱ BuildKit Λ࢖͑ΔΑ͏ʹͨ͠࿩

  17. “࢖͑ΔΑ͏ʹͨ͠࿩” ͳͷͰ ΋ͱ΋ͱ࢖͑ͳ͔ͬͨ

  18. ͳͥͳͷ͔

  19. ͦ΋ͦ΋ docker-composeͷbuild͸ ԿΛ΍͍ͬͯΔͷ͔

  20. docker-composeͷbuild͸ γϯϓϧͰ yamlͷ಺༰͔ΒparameterΛ औΓग़ͯ͠build͢Δ

  21. ͜͜ͰҰ୴

  22. docker build ͷ࢓૊Έ

  23. None
  24. None
  25. None
  26. ؾʹͳͬͨํ͸ https://speakerdeck.com/orisano/container-build-talk

  27. docker-composeࣗମ͸ docker/cli͕ͳͯ͘΋ಈ͘

  28. docker-compose ͸ docker-pyΛ࢖͍ͬͯΔ

  29. docker-py͸ dockerdͷAPIΛୟ͘ python client

  30. None
  31. docker-compose͸ image໊Λ࡞Δ͚ͩͷػߏʹ ͍ۙ

  32. imageʹ {project}_{service} Έ͍ͨͳ໊લΛ͚ͭͯ APIΛݺͿ

  33. ͳͥ BuildKit͕࢖͑ͳ͍ͷ͔

  34. BuildKit͸ ίϯςΩετΛࠩ෼సૹ͢Δ

  35. ࠩ෼సૹ(fssync)͸ grpc

  36. docker-pyʹ͸ͦΕ͕ ࣮૷͞Ε͍ͯͳ͍

  37. pythonͰ࣮૷͢Δͷ͸ ͕͔͔࣌ؒΓͦ͏…

  38. Issue্͕͕ͬͯࢭ·͍ͬͯͨ

  39. ಴࠳

  40. ͱ͸͍͑ docker-compose build ͕஗͍ͷ͸ࠔΔ

  41. ͘͢͝ࠔΔ

  42. @AkihiroSuda͞Μʹ ͱΓ͋͑ͣ૬ஊͯ͠ΈΔ

  43. @AkihiroSuda͞Μ͔Β ʮexec͢Δ΍͕ͭྑͦ͞͏ʯ ͱݴΘΕΔ

  44. ࣮૷ͯ͠PR (—exec) docker/compose#6584 (2019/3/15)

  45. 4/4 thaJeztah͔Βίϝϯτ ΞϧϑΝϕοτॱʹ͠ͳ͍ͷʁ ΋ͱ΋ͱͦ͏͡Όͳ͍

  46. 4/5 ulyssessouza͔Βίϝϯτ ΞϧϑΝϕοτॱʹ͠ͳ͍ͷʁ ΋ͱ΋ͱͦ͏͡Όͳ͍

  47. 4/24 ulyssessouza͔Βίϝϯτ —exec ͬͯඍົ͡Όͳ͍? ͳΜ໊͔͍͍લͳ͍?

  48. 5/16 ulyssessouza͔Βίϝϯτ —cli͕ྑͦ͞͏

  49. 6/6 ulyssessouza ٳΈʹೖΔ

  50. 6/13 thaJeztah͔Βίϝϯτ ̎ͭ͘Β͍ߟ͑Δ͜ͱ͕ ͋Γͦ͏

  51. 6/14 thaJeztah͔Βίϝϯτ ͜͏͍͏ਐΊํͲ͏?

  52. 7/19 thaJeztah͔Βίϝϯτ ulyssessouzaͱٞ࿦ͨ͠

  53. 8/13 ulyssessouza͔Βίϝϯτ —cliΛ΍Ίͨ COMPOSE_NATIVE_BUILDER=1

  54. 8/20 thaJeztah͔Βίϝϯτ docker-compose up —build Ͱ΋ಉ͡ಈ͖Λͯ͠΄͍͠

  55. 8/22 ରԠ

  56. 8/22 PR close(!!!!!!!!)

  57. 8/22 docker/compose#6865 ulyssessouza ʹΑΓ PR͕৽نʹ࡞ΒΕΔ

  58. 8/22~24 ಈ͖ͳ͠

  59. 8/25~8/29 @orisano ࢒՝୊Λશ෦ղܾ

  60. 8/30 ແࣄϚʔδ

  61. ࣍ͷrc͔Β COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 Ͱ࢖͑ΔΑ͏ʹͳΓ·͢

  62. ޤ͏͝ظ଴

  63. ֶͼ

  64. ϑϥάΛ௥Ճ͢Δ͜ͱ͸ ϝϯςφϯείετ͕ ൃੜ͢Δ͜ͱΛҙࣝ͢Δ

  65. ؀ڥม਺͔Β࢝ΊͯΈΔ

  66. ͜΅Ε࿩

  67. docker build ͷ݁Ռ͸ streamͰྲྀΕͯ͘Δͷ͕ͩ

  68. docker-compose͸ͦͷதͷ Successfully Built ͱ͍͏จࣈྻ͔Β ݁ՌΠϝʔδͷid Λऔಘ͍ͯ͠Δ

  69. ϨϏϡʔ࣌ʹ ͳʹ͜ΕͱݴΘΕ͕ͨ ๻΋ͳʹ͜Εͱࢥͬͨ

  70. ͜΅Ε࿩2

  71. ࣮͸͜Εͱಉ࣌ظʹ docker-composeͷ cache-fromͰࠔΔͱ͜Ζ͕ ͋ͬͨͷͰPR

  72. ͦΕ͸͙͢ʹϚʔδ͞Εͨ

  73. cache_fromʹ ؀ڥม਺Λ౉͔ͨͬͨ͠

  74. ౉͢ͱಈ͍ͨ CI͕շదʹͳͬͨ

  75. ϩʔΧϧͰ͸ ຖճϑϧϏϧυ͕ ͸͠ΔΑ͏ʹͳͬͨ

  76. ஍ࠈ

  77. docker buildͷ࢓༷Ͱ —cache-fromʹͳʹ͔౉͢ͱ ϩʔΧϧͷΩϟογϡ͕ ޮ͔ͳ͘ͳΔ

  78. ৄ͘͠͸ ͪΌΜͱཧղ͢Δdocker build cache https://orisano.hatenablog.com/entry/2018/12/17/025931

  79. ࢦఆ͞ΕͨΠϝʔδ͕ ଘࡏ͠ͳ͍৔߹͸ແࢹ͢Δ

  80. ؀ڥม਺ʹͳʹ͔༩͑ͳ͍ͱ cache-fromʹۭจࣈྻ͕…

  81. ࠓͰ͸ docker-composeଆͰ ۭͷΠϝʔδ͸ແࢹ͢Δ Α͏ʹͳΓ·ͨ͠

  82. ΊͰͨ͠

  83. ͜΅Ε࿩3

  84. ࠓճͷPR͸ Ϛʔδ·Ͱ5ϲ݄͔͔ͬͨ

  85. 5ϲ݄ؒ଱͑Δͷ͸ ແཧͩͬͨͷͰखݩͰ͸ ࣗ෼ͷforkΛ࢖͍ͬͯͨ (࢖ͬͯ͘ΕΔϑΝϯͷํ͕͍ͨ)

  86. ͦΕΛϓϩδΣΫτͷ makeʹ௥Ճ͢ΔΘ͚ʹ͸ ͍͔ͳ͔ͬͨ

  87. Ͳ͏ʹ͔Ͱ͖ͳ͍ͩΖ͏͔

  88. ࢥ͍ग़͢

  89. docker-compose͸ image໊Λ࡞Δ͚ͩͷػߏʹ ͍ۙ

  90. imageʹ {project}_{service} Έ͍ͨͳ໊લΛ͚ͭͯ APIΛݺͿ

  91. ͭ·Γ

  92. docker-composeͷ ࢖͏໊લͰdocker build͢Δ ͜ͱʹͯ͠ճආͨ͠

  93. ࠷ߴͷମݧ (΋͏ෆཁͰ͕͢)