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

Dockerの基本

Masanari Kondo
April 15, 2021
240

 Dockerの基本

Masanari Kondo

April 15, 2021
Tweet

Transcript

  1. ίϯςφٕज़Λ࢖͍΍͍͢ܗͰ·ͱΊͨ ιϑτ΢ΣΞ 3 ˔ %PDLFS㱠ίϯςφٕज़ ˔ ίϯςφٕज़͸ιϑτ΢ΣΞΛ։ൃɼ഑෍ɼσϓϩΠ͕ Ͱ͖Δඪ४Խ͞ΕͨܗͰύοέʔδԽ͢Δ͜ͱ<>ʢۙ౻ ༁ʣ POSL@Kyushu

    University: <>IUUQTXXXEPDLFSDPNSFTPVSDFTXIBU DPOUBJOFSdUFYU"DPOUBJOFSJTBTUBOEBSE POFDPNQVUJOHFOWJSPONFOUUPBOPUIFSUFYU"WBJMB CMFGPSCPUI-JOVYBOE TBNF$SFHBSEMFTTPGUIFJOGSBTUSVDUVSF 04 ґଘύοέʔδ ґଘύοέʔδ/ ͋Διϑτ΢ΣΞ ɾɾɾ
  2. Docker͕ͳͥඞཁʁ 6 POSL@Kyushu University: ։ൃऀ" "ͷ࣮ߦ؀ڥ ։ൃ͍ͯ͠Δ ιϑτ΢ΣΞ ຊ൪؀ڥ ։ൃ͍ͯ͠Δ

    ιϑτ΢ΣΞ ಈ͔ͳ͍ͧ ˔ "ͷ࣮ߦ؀ڥͱຊ൪؀ڥͷҧ ͍͸ʁ ˔ "ͷ࣮ߦ؀ڥͷৄࡉ͸Ͳ͏ ΍ͬͯݟΕ͹ʁ ˔ ύοέʔδͷόʔδϣϯ͸ʁ
  3. Docker͕ͳͥඞཁʁ 7 POSL@Kyushu University: ։ൃऀ" "ͷ࣮ߦ؀ڥ ։ൃ͍ͯ͠Δ ιϑτ΢ΣΞ ຊ൪؀ڥ ։ൃ͍ͯ͠Δ

    ιϑτ΢ΣΞ %PDLFSͰύοέʔδԽ ˔ %PDLFS͕ಈ͘ͷͰ͋Ε͹࣮ߦՄೳ ˔ ޙड़͢Δ%PDLFS fi MF΍EPDLFSDPNQPTFΛ࢖͑͹؀ڥΛه ड़Ͱ͖Δ *OGSBTUSVDUVSFBT$PEF *B$
  4. ݚڀऀʹ͋Γ͕ͪͳύλʔϯ 8 ˔ ͦͷ࣌ʑͷ࢖༻ऀ͕ࣗ༝ؾ··ʹΠϯετʔϧ༷ͨ͠ʑͳύοέʔδɽԿ͕ ೖ͍ͬͯΔͷ͔Α͘Θ͔Βͳ͍ɽ ˔ ͱΓ͋͑ͣͳΜͱͳ͘ಈ͔͘Βͦͷ··์ஔ͍ͯ͠Δɽ࣌ʑಈ͔ͳ͘ͳͬ ͯɼͦͷ࣌ͷ༗ࣝऀ͕৔౰ͨΓతͳॲஔΛ͢ΔɽҰےೄͰ͸࣏Βͳ͍ͷͰɼ ௚͠ํ͸୭΋ॻ͍͓͔ͯͳ͍ʢຖճ͕࣌ؒେྔʹऔΒΕΔʣ ˔

    αʔόΛΈΜͳ࢖ͬͯΔ͔ΒαʔόͰ࣮ߦ͠Α͏ͱࢥͬͨΒɼಈ͘؀ڥΛ ੔͑ΒΕͳ͍ɽ ˔ ؀ڥΛഁյ͢Δ͜ͱ͕ාͯ͘04ͷΞοϓσʔτͱ͔΋Ͱ͖ͳ͍ɽ POSL@Kyushu University: ݹ୅ͷҨ࢈αʔό ݹ୅ͷҨ࢈αʔό ݹ୅ͷҨ࢈αʔό/ ɾɾɾ
  5. PythonΛ࣮ߦͰ͖Δίϯςφͷੜ੒ͱ࣮ߦ 12 ˔ EPDLFSQVMMQZUIPOTMJNCVTUFS ˔ ্Ͱ1ZUIPOͷΠϝʔδΛμ΢ϯϩʔυ ˔ EPDLFSJNBHFMT ˔ ্ͰϩʔΧϧʹ͋ΔΠϝʔδͷҰཡΛ֬ೝ

    ˔ EPDLFSDPOUBJOFSSVOQZUIPOTMJNCVTUFS QZUIPODlQSJOU bUFTU` z ˔ ্Λ࣮ߦ͢ΔͱɼUFTUͱ͍͏จࣈྻ͕ग़ྗ͞ΕΔɽ͜ͷ UFTUͱ͍͏จࣈྻ͸1ZUIPOʹΑΓ࣮ߦ͞Ε͍ͯΔ͕ɼ͜ Ε͕%PDLFSͷίϯςφͱͯ͠࡞੒͞Ε࣮ߦ͞Εͨɽ POSL@Kyushu University:
  6. ੜ੒ͨ͠ίϯςφͷ֬ೝͱ࡟আ 13 ˔ EPDLFSDPOUBJOFSMTB ˔ ্Ͱɼࠓ·Ͱʹੜ੒ͨ͠ίϯςφͷҰཡΛ֬ೝͰ͖Δ ˔ EPDLFSDPOUBJOFSSN\\ZPVSDPOUBJOFS*%^^ ˔ ίϯςφ͸ଘࡏ͢Δ͚ͩͰ΋༰ྔΛ৯͏ͷͰɼ্ͷίϚϯ

    υͰ࡟আ͓ͯ͘͠ɽ\\ZPVSDPOUBJOFS*%^^ͷ෦෼͸্ͷMT Ͱग़ྗ͞Εͨ΋ͷΛར༻͢Δɽ ˔ ͪͳΈʹɼ࣮ߦͨ͠ޙʹίϯςφΛࣗಈͰ࡟আ͢Δ͜ͱ΋ Ͱ͖Δɽྫ͑͹ҎԼɽSN͕ೖ͍ͬͯΔ ˔ EPDLFSDPOUBJOFSSVOSNQZUIPOTMJNCVTUFS QZUIPODlQSJOU bUFTU` z POSL@Kyushu University:
  7. ਤղͯ͠Έͨ 16 POSL@Kyushu University: 1ZUIPOͷ ίʔυΛ࣮ߦͯ͠ զʑ 1$ 5FTUͱ͍͏ ग़ྗ݁Ռ

    1ZUIPOͷ ίʔυΛ࣮ߦ͢Δ ίϯςφΛੜ੒͠ ࣮ͯߦͯ͠ զʑ 1$ 5FTUͱ͍͏ ग़ྗ݁Ռ %PDLFSͷ ίϯςφ
  8. ਤղͯ͠Έͨ 17 POSL@Kyushu University: 1ZUIPOͷ ίʔυΛ࣮ߦͯ͠ զʑ 1$ 5FTUͱ͍͏ ग़ྗ݁Ռ

    1ZUIPOͷ ίʔυΛ࣮ߦ͢Δ ίϯςφΛੜ੒͠ ࣮ͯߦͯ͠ զʑ 1$ 5FTUͱ͍͏ ग़ྗ݁Ռ %PDLFSͷ ίϯςφ ͜͜Λίϯςφͷதʹ ด͡ࠐΊΔ ͜ͱ͕Ͱ͖Δ
  9. ίϯςφͷதʹೖͬͯΈΔ 18 ˔ EPDLFSDPOUBJOFSSVOJUSNQZUIPOTMJN CVTUFSCBTI ˔ ্Λ࣮ߦ͢ΔͱɼQZUIPOTMJNCVTUFSͱ͍͏Πϝʔδ ͕ੜ੒͢ΔίϯςφͰCBTIΛىಈͯ͠ɼͦͷ୺຤Λಘ͍ͯ Δɽ͜͜Ͱ͸௨ৗͷ୺຤ͱಉ༷ʹ৭ʑͳૢ࡞͕ߦ͑Δɽ ʢCBTFJNBHF͸EFCJBOͳͷͰɼૢ࡞͸ͦΕʹ४ڌ͢Δʣɽ

    FYJUͰ୺຤ΛमྃͰ͖Δɽ ˔ ઌఔͷίϚϯυ͸ͭ·Γɼ͜ͷ୺຤্ͰQZUIPOD lQSJOU bUFTU` zΛ࣮ߦͨ͠ͷͱಉ͡Ͱ͋Δɽ ˔ ΍Γ͍ͨ͜ͱͱͯ͠͸ɼ͜ͷ୺຤্Ͱ؀ڥΛߏஙͯ͠͠· ͍ɼ࣮ݧεΫϦϓτͷ࣮ߦ·Ͱߦͬͯ͠·͍͍ͨɽ POSL@Kyushu University:
  10. ਤղͯ͠Έͨ 20 POSL@Kyushu University: զʑ 1$ 5FTUͱ͍͏ ग़ྗ݁Ռ %PDLFSͷ ίϯςφ

    ͜͜Λίϯςφͷதʹ ด͡ࠐΊΔ ͜ͱ͕Ͱ͖Δ ͕͜͜ผͷ1$ͷΑ͏ͳΠϝʔδ ͪ͜Βͷ؀ڥʹґଘ͠ͳ͍
  11. ઌఔͷܭࢉΛDocker fi leͰද͢ͱҎԼʹͳΔ 23 POSL@Kyushu University: %PDLFS fi MF '30.QZUIPOTMJNCVTUFS

    803,%*3IPNF 36/QJQJOTUBMMOVNQZa FDIPJNQPSUOVNQZBTOQUFTUQZa FDIPQSJOU OQQFSDFOUJMF <    >  UFTUQZ &/53:10*/5<VTSMPDBMCJOQZUIPO> $.%<UFTUQZ>
  12. ઌఔͷܭࢉΛDocker fi leͰද͢ͱҎԼʹͳΔ 24 POSL@Kyushu University: %PDLFS fi MF '30.QZUIPOTMJNCVTUFS

    803,%*3IPNF 36/QJQJOTUBMMOVNQZa FDIPJNQPSUOVNQZBTOQUFTUQZa FDIPQSJOU OQQFSDFOUJMF <    >  UFTUQZ &/53:10*/5<VTSMPDBMCJOQZUIPO> $.%<UFTUQZ> ϕʔεΠϝʔδΛࢦఆ Ҏ߱ͷίϚϯυ͕࣮ߦ͞ΕΔσΟϨΫτϦࢦఆ ೚ҙͷίϚϯυΛ࣮ߦ ίϯςφͷ࣮ߦΛݶఆ͢Δ &/53:10*/5ͷΦϓγϣϯɾ࣮ߦ͢ΔίϚϯυ
  13. Docker fi leͷ࣮ߦํ๏ 25 ˔ %PDLFS fi MF͸Ϗϧυͯ͠ΠϝʔδΛ࡞੒͠ɼΠϝʔδΛ΋ͱʹί ϯςφΛੜ੒࣮ͯ͠ߦ͠ͳ͚Ε͹ͳΒͳ͍ɽ ˔

    EPDLFSCVJMEUBHUFTUQZUIPO ˔ ·ͣ͸্ͷίϚϯυΛ%PDLFS fi MF͕͋ΔσΟϨΫτϦͰ࣮ߦ͠ ͯϏϧυ͢ΔɽUBHΦϓγϣϯ͸ɼΠϝʔδͷ໊લʹͳΔɽͷ લ͕ϦϙδτϦ໊ɼޙ͕λάʹͳΔɽ ˔ EPDLFSJNBHFMTB ˔ ্ͰΠϝʔδͷҰཡΛ֬ೝͰ͖Δ ˔ EPDLFSDPOUBJOFSSVOSNUFTUQZUIPO ˔ ͋ͱ͸ࠓ·Ͱͱಉ༷ʹ࣮ߦ͢Δɽͨͩ͠ɼ࡞੒ͨ͠ΠϝʔδΛ ࣮ߦର৅ͱ͢Δɽ POSL@Kyushu University:
  14. DockerͰϑΝΠϧ͕ফ͑Δ͜ͱΛ֬ೝ 28 ˔ EPDLFSDPOUBJOFSSVOJUSNQZ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FSDPOUBJOFSSVOJUSNNPVOU UZQFCJOE TPVSDF\\εΫϦϓτͷ֨ೲ৔ॴ^^ UBSHFU IPNF\\೚ҙͷΠϝʔδ^^CBTI ˔ ্Ͱ୺຤Λ্ཱͪ͛ͯɼͦ͜Ͱ؀ڥΛߏஙͨ͠ΓɼεΫ

    ϦϓτΛվྑͨ͠Γʢ͜Ε͸ϩʔΧϧͰ΍Δʣ࣮ͯ͠ݧ εΫϦϓτΛ࡞͍ͬͯ͘ɽ؀ڥߏங࣌ʹ͸ͦͷ಺༰͸ %PDLFS fi MFͱͯ͠ॻ͖ࠐΜͰ͍͘ ˔ ςετͳͲ΋ऴΘͬͨΒɼ%PDLFS fi MFΛ׬੒ͤͯ͞ɼ EPDLFSDPNQPTFZNMΛॻ͖ɼ࣮ݧ༻ͷܭࢉػ΁ૹΔɽ ˔ ࣮ߦɽ POSL@Kyushu University:
  18. pipenvͱ૊Έ߹Θͤͨํ๏ 32 ˔ QJQFOWͰ؀ڥΛߏங࣮ͯ͠ݧεΫϦϓτΛ࡞Δ ˔ 1JQ fi MFͱ1JQ fi MFMPDLΛ࢖͏ͱ؀ڥΛ࠶ݱͰ͖ΔͷͰɼ͜

    ΕΛ%PDLFS fi MFͰ࠶ݱͰ͖ΔΑ͏ʹͯ͠΍Δ ˔ ςετͳͲ΋ऴΘͬͨΒɼ%PDLFS fi MFΛ׬੒ͤͯ͞ɼ EPDLFSDPNQPTFZNMΛॻ͖ɼ࣮ݧ༻ͷܭࢉػ΁ૹΔɽ ˔ ࣮ߦɽ POSL@Kyushu University: