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

Dockerよちよち歩きハンズオン / Docker hands-on for beginners

ihcomega56
October 05, 2021

Dockerよちよち歩きハンズオン / Docker hands-on for beginners

ihcomega56

October 05, 2021
Tweet

More Decks by ihcomega56

Other Decks in Technology

Transcript

  1. 2 ࣗݾ঺հ Α͜ͳ "ZBOB:PLPUB • +'SPHͷ%FWFMPQFS"EWPDBUF • લ৬·Ͱ͸ओʹόοΫΤϯυͷ։ൃ ʢ4*FS ޿ࠂձࣾ

    ূ݊ελʔτΞοϓʣ • ࠷ۙɺੜ·ΕͯॳΊͯಉ͡өըΛ౓؍ͨ !"#$$%&' (#)*+,%-.
  2. • ίϯςφΛ࡞੒͢ΔͨΊͷ໋ྩ͕ೖͬͨύοέʔδ • طʹଘࡏ͢Δ΋ͷΛ࢖͏͜ͱ΋ɺ࡞Δ͜ͱ΋Ͱ͖Δ • Πϝʔδ͕࣮ߦঢ়ଶʹͳͬͨΠϯελϯε͕ίϯςφ  %PDLFSΠϝʔδ %PDLFS Πϝʔδ

    ࣮ߦ؀ڥͱͯ͠"MQJOF ܰྔͷ-JOVY Λ࢖ͬͯʂ +BWBͱ(SBEMFΛΠϯετʔϧͯ͠ʂ ࣮ߦϑΝΠϧ͸͜ͷσΟϨΫτϦʹ഑ஔͯ͠ʂ +BWBΞϓϦέʔγϣϯΛ࣮ߦͯ͠ʂ
  3. ҎԼͷ͍ͣΕ͔ͰΠϝʔδΛಛఆ͢Δ • *% • Πϝʔδ໊<λά໊> • Πϝʔδ໊<!μΠδΣετ஋>  %PDLFSΠϝʔδͷಛఆɾ࣮ߦ ίϯςφΛ࡞੒ɾ࣮ߦ͢Δ

    docker run σϑΥϧτ͸ϑΥΞάϥ΢ϯυ ࣮ߦɻόοΫάϥ΢ϯυʹ͢Δ ʹ͸EΦϓγϣϯΛ͚ͭΔ ίϯςφΛ࡞੒͢Δ docker create ίϯςφΛ࣮ߦ͢Δ docker start
  4. • FROM ϕʔεͱͳΔΠϝʔδΛࢦఆ͢Δ • RUN Ϗϧυ࣌ʹίϯςφ಺ͰίϚϯυΛ࣮ߦ͢Δ • ENV ,FZ7BMVFܗࣜͰ؀ڥม਺Λࢦఆ͢Δ •

    ADD, COPY Πϝʔδ಺΁ϑΝΠϧΛίϐʔ͢Δ ˠ<ϦϯΫ>"%%ͱ$01:جຊ͸$01:Λ࢖͏ • CMD, ENTRYPOINT ίϯςφىಈ࣌ʹ࣮ߦ͢ΔίϚϯυ΍Ҿ਺Λ ͋ ࢦఆ͢Δ ˠ<ϦϯΫ>$.%ͱ&/53:10*/5ͷ૊Έ߹Θͤ  جຊతͳ%PDLFSGJMFͷίϚϯυ
  5. • LABEL • EXPOSE • VOLUME • USER • WORKDIR

    • ARG • ONBUILD • STOPSIGNAL • HEALTHCHECK • SHELL  ͦͷଞͷ%PDLFSGJMFͷίϚϯυ STNUVW XYZ[Z>@
  6.  Α͘࢖͏ίϯςφͷૢ࡞ ίϯςφΛҰཡදࣔ͢Δ docker ps ࣮ߦ த ఀࢭ த ίϯςφΛఀࢭ͢Δ

    docker stop ίϯςφΛىಈ͢Δ docker start ࣮ߦதͷίϯςφ಺ͰίϚϯυΛ࣮ߦ͢Δ docker exec ίϯ ςφ ࣮ߦதͷίϯςφ಺ͷϩάΛग़ྗ͢Δ docker logs ίϯςφΛ࡟আ͢Δ docker rm ର৅͸ఀࢭதͷίϯςφɻ ಈ͍͍ͯΔ΋ͷΛࢭΊΔ࣌͸ GΦϓγϣϯΛ͚ͭΔ ͪΐͬͱ͓ͨ͠ࢼ͠΍ ௐࠪʹ࢖͏͜ͱ͕ଟ͍ ର৅͸࣮ߦதͷίϯςφɻ ࢭ·͍ͬͯΔ΋ͷ΋ݟΔ࣌͸ BΦϓγϣϯΛ͚ͭΔ
  7.  ΞϓϦέʔγϣϯͷίϯςφԽ • ݴޠ΍ϑϨʔϜϫʔΫʹΑͬͯ΍Γํ͸ͦΕͧΕ͕ͩɺࢿྉ͸ ͨ͘͞Μ͋ΔͷͰ ࠷ۙ͸ެࣜυΩϡϝϯτ΋๛෋ ࢀߟʹͯ͠ ࣮ݱͰ͖Δ • جຊతʹ͸࣍ͷ͍ͣΕ͔ͷํ਑Ͱ%PDLFSGJMFΛॻ͍͍ͯ͘

    • ιʔείʔυΛίϯςφʹίϐʔ͠ɺΠϝʔδͷϏϧυ࣌ʹΞϓϦ έʔγϣϯ΋Ϗϧυ͢Δ • Ϗϧυͨ͠ΞϓϦέʔγϣϯͷ࣮ߦϑΝΠϧΛίϯςφʹίϐʔ͢Δ
  8.  αϯϓϧΞϓϦέʔγϣϯ ࣮ߦ ϑΝΠϧ ιʔε ίʔυ \]2N0^_ `[a18N 8b0NW@ Ϗϧυ͢Δ

    HSBEMFX CPPU+BS ࣮ߦ͢Δ KBWBKBSBQQIBOETPOKBS ˞αϯϓϧͷίϯςφ಺Ͱ͸ KBWB KBSBQQKBS
  9.  αϯϓϧΞϓϦέʔγϣϯ ࣮ߦ ϑΝΠϧ ΞϓϦ༻ ίϯςφ ᶃίϐʔ ᶄίϯςφ಺Ͱ࣮ߦ %#༻ ίϯςφ

    ᶅσʔλ$36% ࠓճ͸औಘͷΈ ಉ͡ωοτϫʔΫ಺Ͱ ίϯςφΛσΟεΧόϦ Ͱ͖ΔΑ͏ʹ͢Δ
  10.  %PDLFS$PNQPTF • ෳ਺ͷίϯςφΛఆٛɾ࣮ߦ͢ΔͨΊͷπʔϧίϚϯυͰ ·ͱΊͯىಈɾఀࢭͰ͖Δ • :".- EPDLFSDPNQPTFZNM ͰઃఆΛॻ͖ίϯςφΛ؅ཧ͢Δ •

    %PDLFSGJMFͱ૊Έ߹ΘͤͯϏϧυΛߦ͏͜ͱ΋ɺΠϝʔδ͚ͩ ར༻͢Δ͜ͱ΋Ͱ͖Δ • %PDLFSGJMFʹهࡌͨ͠ઃఆΛ্ॻ͖͢Δ͜ͱ΋Ͱ͖Δ • ઃఆϑΝΠϧ্ͷίϯςφ͕ࢀՃ͢ΔωοτϫʔΫΛઃఆ͢Δ
  11.  ͖ͬ͞΍ͬͨ͜ͱ ͓͞Β͍ ࣮ߦ ϑΝΠϧ ΞϓϦ༻ ίϯςφ ᶃίϐʔ ᶄίϯςφ಺Ͱ࣮ߦ %#༻

    ίϯςφ ᶅσʔλ$36% ࠓճ͸औಘͷΈ ಉ͡ωοτϫʔΫ಺Ͱ ίϯςφΛσΟεΧόϦ Ͱ͖ΔΑ͏ʹ͢Δ