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

Gitlab-RunnerからDockerコンテナを起動して テストする構成を用意した

Aipa
August 27, 2021

Gitlab-RunnerからDockerコンテナを起動して テストする構成を用意した

やらないほうが良い構成なので注意

Aipa

August 27, 2021
Tweet

More Decks by Aipa

Other Decks in Technology

Transcript

  1. Gitlab ΅ͨͪ͘ Gitlab Runner CI࣮ߦϑϩʔ Docker compose $ docker-compose down

    $ docker-compose rm ʘόΠόΠʗ ʘ·ͨͶʗʘ͡Ό͋ͷʗ %PDLFSEFBNPO
  2. ΍Γํ͸̎ͭ • Docker in Dockerʢdindʣ • Dockerίϯςφ಺͔ΒDockerΛ࢖͏ • Docker outside

    of Docker (dood) • Dockerίϯςφىಈ࣌ʹϗετͷDocker deamonͷ socket fileΛϚ΢ϯτͯ͠ɺϗετͷDocker deamonͱ΍ ΓऔΓͰ͖ΔΑ͏ʹ͢Δ • ͙͙ͬͯΈΔͱͬͪ͜ͷ΄͏͕Gitlab-runnerʹ͸͍͋ͬͯ ΔΑ͏ͳͷͰͬͪ͜ʹͨ͠ • https://jpetazzo.github.io/2015/09/03/do-not-use- docker-in-docker-for-ci/
  3. Gitlab ΅ͨͪ͘ Gitlab Runner %PDLFSEFBNPO ͞Βʹʁ $ docker-compose up )PTU

    WBSSVOEPDLFSTPDL Docker compose WBSSVOEPDLFSTPDL
  4. Gitlab ΅ͨͪ͘ Gitlab Runner %PDLFSEFBNPO ͞Βʹʁ $ docker-compose up )PTU

    WBSSVOEPDLFSTPDL Docker compose WBSSVOEPDLFSTPDL CJOENPVOU
  5. Gitlab Runner %PDLFSEFBNPO )PTU WPMVNF Docker compose ϋϚΓϙΠϯτ ͬͪ͜ʹॻ͖ࠐ·ΕΔ WPMVNF

    Gitlab ΅ͨͪ͘ $ docker-compose up WPMVNF WPMVNF ͬͪ͜ ʹ͸ͳ͍ ͬͪ͜ʹ ΋͸ͳ͍ ͬͪ͜ʹ͸ͳ͍ ϓϩδΣΫτͷ ιʔείʔυ͸ʁ ɾТɾʆ ʁ
  6. Gitlab Runner %PDLFSEFBNPO )PTU WPMVNF Docker compose ϋϚΓϙΠϯτ ͬͪ͜ʹॻ͖ࠐ·ΕΔ WPMVNF

    Gitlab ΅ͨͪ͘ $ docker-compose up WPMVNF WPMVNF ͬͪ͜ ʹ͸ͳ͍ ͬͪ͜ʹ ΋͸ͳ͍ ͬͪ͜ʹ͸ͳ͍ ϓϩδΣΫτͷ ιʔείʔυ͸ʁ ɾТɾʆ ʁ ಈ͔ͳ͍
  7. Gitlab Runner %PDLFSEFBNPO )PTU WPMVNF Docker compose Ϛ΢ϯτ͢Ε͹͑͑΍Μ WPMVNF Gitlab

    ΅ͨͪ͘ $ docker-compose up WPMVNF WPMVNF ͍ͭ΋ͷ W QXE CVJMETHSPVQQSPKFDU
  8. Gitlab Runner %PDLFSEFBNPO )PTU WPMVNF Docker compose Ϛ΢ϯτ͢Ε͹͑͑΍Μ WPMVNF Gitlab

    ΅ͨͪ͘ $ docker-compose up WPMVNF WPMVNF ͍ͭ΋ͷ W QXE CVJMETHSPVQQSPKFDU ͬͪ͜ʹ͸ͳ͍ ϓϩδΣΫτͷ ιʔείʔυ͸ʁ ɾТɾʆ ʁ
  9. Gitlab Runner %PDLFSEFBNPO )PTU WPMVNF Docker compose Ϛ΢ϯτ͢Ε͹͑͑΍Μ WPMVNF Gitlab

    ΅ͨͪ͘ $ docker-compose up WPMVNF WPMVNF ͍ͭ΋ͷ W QXE CVJMETHSPVQQSPKFDU ͬͪ͜ʹ͸ͳ͍ ϓϩδΣΫτͷ ιʔείʔυ͸ʁ ɾТɾʆ ʁ ಈ͔ͳ͍
  10. Gitlab Runner %PDLFSEFBNPO )PTU WPMVNF Docker compose ͳͥʁʁʁ WPMVNF Gitlab

    ΅ͨͪ͘ $ docker-compose up CVJMETHSPVQQSPKFDUCVJMETHSPVQQSPKFDU WPMVNF W QXE CVJMETHSPVQQSPKFDU  QXE ͸%PDLFSDPNQPTFίϯςφ্͔Βࢀর ͨ݁͠ՌͷσΟϨΫτϦͰ͋ΔʢͦΕ͸ͦ͏ʣ ྫ͑͹ QXE ˠCVJMETHSPVQQSPKFDUͱ͢Δ ͕ɺϚ΢ϯτ͞ΕΔͷ͸ϗετଆͷ σΟϨΫτϦύεΛϚ΢ϯτ͠Α͏ͱ͢Δ Ϛ΢ϯτ͍ͨ͠ͷ͸ͬͪ͜ ͦ͏͡Όͳͯ͘ɺϗετͷ CVJMETHSPVQQSPKFDU ΛϚ΢ϯτ͠Α͏ͱ͢Δ WPMVNF
  11. Gitlab Runner %PDLFSEFBNPO )PTU WPMVNF ϗετϚ΢ϯτͨ͠Β͑͑΍Μʂʂ IPNFVCVOUVBQQ Gitlab ΅ͨͪ͘ WPMVNF

    WPMVNF $ docker-compose down $ docker-compose rm ʘόΠόΠʗ ʘ·ͨͶʗʘ͡Ό͋ͷʗ ফ͑ͳ͍ ΰϛ͕࢒Δ ଟ෼ɺ(JUMBC3VOOFSͷ ઃఆͰͰ͖ΔͬΆ͍͚Ͳ ΍Γ͔͕ͨΘ͔ΒΜɾɾɾ
  12. Gitlab Runner %PDLFSEFBNPO )PTU WPMVNF IPNFVCVOUVBQQ Gitlab ΅ͨͪ͘ WPMVNF WPMVNF

    $ docker-compose down $ docker-compose rm ʘόΠόΠʗ ʘ·ͨͶʗʘ͡Ό͋ͷʗ ফ͑ͳ͍ ΰϛ͕࢒Δ ଟ෼ɺ(JUMBCSVOOFSͷઃ ఆͰͰ͖ΔͬΆ͍͚Ͳ΍ Γ͔͕ͨΘ͔ΒΜɾɾɾ ΰϛ͸ย෇͚͍ͨ
  13. Gitlab Runner %PDLFSEFBNPO )PTU Docker compose ਆͷखॱ Gitlab ΅ͨͪ͘ 

    ࠓͷ+PCͰىಈ͍ͯ͠Δ$POUBJOFSJEΛ୳͢  $POUBJOFSJE͔ΒϚ΢ϯτ͍ͯ͠ΔWPMVNF ͷϗετͷσΟϨΫτϦύεΛ୳͢  ͷ݁ՌΛ؀ڥม਺ʹೖΕΔ  EPDLFSDPNQPTFVQ
  14. Gitlab Runner %PDLFSEFBNPO )PTU Docker compose ਆͷखॱ Gitlab ΅ͨͪ͘ 

    ࠓͷ+PCͰىಈ͍ͯ͠Δ$POUBJOFSJEΛ୳͢ FYQPSU$0/5"*/&3@*%AEPDLFSQTRGlMBCFMDPNHJUMBCHJUMBCSVOOFSKPCJE$*@+0#@*%A
  15. Gitlab Runner %PDLFSEFBNPO )PTU Docker compose ਆͷखॱ Gitlab ΅ͨͪ͘ $POUBJOFSJE͔ΒϚ΢ϯτ͍ͯ͠ΔWPMVNFͷϗετͷσΟϨΫτϦύεΛ୳͢

    FYQPSU.:@130+&$5@1"5)AEPDLFSJOTQFDUG\\SBOHF.PVOUT^^\\JGFR%FTUJOBUJPOaCVJMETa^^\\4PVSDF^^\\FOE^^\\FOE^^$0/5"*/&3@*%A WPMVNF ͍ͭ͜ͷϗετͷσΟϨΫτϦύεΛऔಘ͢Δ WBSMJCEPDLFSWPMVNFTSVOYYYYYYGCKRYYYYYYYYYDPODVSSFOUYYYYYYYYYYEDYYYYYYYYY@EBUB
  16. Gitlab Runner %PDLFSEFBNPO )PTU WPMVNF Docker compose ਆͷखॱ WPMVNF Gitlab

    ΅ͨͪ͘ $ docker-compose up WPMVNF WPMVNF Ϛ΢ϯτͰ͖ͨʂʂʂ
  17. Gitlab Runner %PDLFSEFBNPO )PTU WPMVNF Docker compose ਆͷखॱ WPMVNF Gitlab

    ΅ͨͪ͘ $ docker-compose up WPMVNF WPMVNF Ϛ΢ϯτͰ͖ͨʂʂʂ Α͔ͬͨͶʙʙʙ