Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

コンテナに挫折したあなたへ / A Letter to Uncontainerized Apps

コンテナに挫折したあなたへ / A Letter to Uncontainerized Apps

おコンテナが自分たちのアプリやワークフロー、運用にフィットしないのはなんでなのか?

Presented at JAWS DAYS 2017.

Tori Hara

March 11, 2017
Tweet

More Decks by Tori Hara

Other Decks in Technology

Transcript

  1. SUPINF Inc. // twitter.com/toricls $ ps aux USER PID ...

    COMMAND root 3123 ... /agent root 16293 ... puma 3.6.0 (tcp://0.0.0.0:80) [app] ... Docker୦ŵƓƫƆŸ෇ ǗȗǪǮƛȱƕу $ docker ps CONTAINER ID IMAGE COMMAND ... 533c36714f42 my-rails-app:latest "bundle exec rails s ..." ... 5d48c82b7faa amazon/amazon-ecs-agent:latest "/agent" ... # ps aux USER PID ... COMMAND root 1 ... puma 3.6.0 (tcp://0.0.0.0:80) [app] root 18 ... sh ... Docker Container Docker Engine Host OS $ ps aux USER PID ... COMMAND root 3123 ... /agent root 16293 ... puma 3.6.0 (tcp://0.0.0.0:80) [app] ... $ docker ps CONTAINER ID IMAGE COMMAND ... 533c36714f42 my-rails-app:latest "bundle exec rails s ..." ... 5d48c82b7faa amazon/amazon-ecs-agent:latest "/agent" ... # ps aux USER PID ... COMMAND root 1 ... puma 3.6.0 (tcp://0.0.0.0:80) [app] root 18 ... sh ... Docker Container Docker Engine Host OS
  2. SUPINF Inc. // twitter.com/toricls AMI (Amazon ϚγϯΠϝʔδ) Amazon EC2 Πϯελϯε

    RUN Docker୦ŵƓƫƆŸ෇ ţLjȅȜǜŤƕţǗȗǪǮŤ RUN Ɨ Docker LjȅȜǜ Docker ǗȗǪǮ
  3. SUPINF Inc. // twitter.com/toricls Docker୦ŵƓƫƆŸ෇ ǗȗǪǮƿ̿ŸƆ Docker Hub / Docker

    Registry $ docker pull nginx:latest Ɨ $ docker run nginx:latest
  4. SUPINF Inc. // twitter.com/toricls $ cat Dockerfile $ cat Dockerfile

    FROM ubuntu:16.04 RUN \ apt-get update && \ apt-get install -y nginx EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] Docker୦ŵƓƫƆŸ෇ LjȅȜǜƿʊƸ $ cat Dockerfile FROM ubuntu:16.04 RUN \ apt-get update && \ apt-get install -y nginx EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] $ docker build -t my-awesome-nginx . ... ... $ cat Dockerfile FROM ubuntu:16.04 RUN \ apt-get update && \ apt-get install -y nginx EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] $ docker build -t my-awesome-nginx . ... ... $ docker run -p 80:80 my-awesome-nginx ...
  5. SUPINF Inc. // twitter.com/toricls Docker୦ŵƓƫƆŸ෇ DOCKER ƿʎųࢪࣇ ▶︎ ǪǝǬƄƌdžȜǪLJǹDžǓǬƿƊƛƫƫǫǻȑLjƔźƸȁȜǣǷȎǪLJ ▶︎

    džǻȎҩ଻ࢷЭƛҥ਱"MAICPDGJC ŹǴȜǜȋȗভࢪƔźƸǬȐȜǙǷȎǪLJ ▶︎ ɤƛǻȑǟǝŸƶ൭ԽƘ೴ആƂƹƌҩ଻ࢷЭ ▶︎ LjȅȜǜ˪ۍƛহʛ֕ ▶︎ ӒƗűǎȜǴȜǼǧǭƔ൭ఽƘdžǻȎǕȜǛȋȗƿ௲̿ƔźƸʟ٭֕ ▶︎ ऩܵҴڠ֕ ▶︎ ൭ఽƗǫȎǴȎȜǙLjǓȏƥƛ୨θ֕
  6. SUPINF Inc. // twitter.com/toricls "Build, Ship, and Run Any App,

    Anywhere" https://www.docker.com Docker୦ŵƓƫƆŸ෇ DOCKER ƛௐ́
  7. SUPINF Inc. // twitter.com/toricls ▶︎ ǟǧǬdžǧǻઈ͎̿ƛƌƮƘҫ୭ࣶƗǹǍȜȂǧǬƿʎűřǻȑǜNjǓǬƘډƄż̲ƼƐƌ್ࣲ ਾŹୟƆƸڪ೐ƕǗǝǬŹۋӑ͎ƂƹƓűƸ ▶︎ -1ƥƛʓґ೑ʜƿڞऺ͎Ƅřҩ଻ࢷЭ೐Ɣƛ१݁֕ƿۋш͎ƂƹƓűƸ ▶︎

    ȆǤȗƗǓȍNJǭǻȍǧǬǹǍȜȄȥƥƛǫǻȑLjƘౖƄƓŷƷřǙȜǴȜভࢪƱǛǝǪȄভࢪ ŹȧୟƔůƸ ▶︎ ್ࣲࢷЭƕۙࣘࢷЭƛԎࣙƿۋӑೠƘƄřdžǜȎǪLJƿۋш͎ƆƸ৻ৼࣶǫǻȑLjŹΏ੧ ▶︎ ǨȜȏřdžȜǑǪǓǥȇř್ࣲǻȍǓǪLJǝƿшԤƘрۅƆƸƀƕƗżǝǕȜȏdžǧǻƔźƸ 12-Factor AppƘŷžƸ"ટű"džǻȎǕȜǛȋȗƛҥ਱ https://12factor.net/ja see also https://www.slideshare.net/AmazonWebServicesJapan/aws-black-belt-online-seminar-2017-docker-on-aws
  8. SUPINF Inc. // twitter.com/toricls ƔřƖųƆƹƝűűƛŸ ǥȜȄʇ̛ƕǫȎǴȎȜ džǻȎǕȜǛȋȗ ోࣄ Ljȗǹȍݙ঵ ƿڞऺƘƄřʈŹݸžƓűƸƛŸƿƜƐźƷƂƈƸ

    ǗȗǪǮƘ ౖƄƌ džǻȎઈʇƛ஋ƱోࣄƘƑűƓƜ ̫ƕ12-Factor AppƔ஘ڞƂƹƓűƸƛƔ ɟڒƜȵƘǫȎǴȎȜƕLjȗǹȍƛ஋ƿƄƫƆ
  9. SUPINF Inc. // twitter.com/toricls ǗȗǪǮڪɨƛǫȎǴȎȜȆǫȏ Registry ǗȗǪǮভࢪǨȜȏ  ҩ଻ࢷЭ džȜǪLJǹDžǓǬਧźМƛȐǜǝǬȎř

    ǗȗǪǮƛҩ଻ƿভࢪƆƸǨȜȏŹࣳМƄř ǫǻȑLjƱȎȎȜǝƛȫ࣍Ƙţ˪఻୭கȆǫȏŤŹ ࣁƫƹƌ
  10. SUPINF Inc. // twitter.com/toricls ǗȗǪǮڪɨƛǫȎǴȎȜȆǫȏ ݔୟ Registry 1. build 2.

    ship 2. ship 3. run Docker LjȅȜǜ ҥ਱Ƙ߁Ɛƌ ҩ଻ƿؙु "ҩ଻ҥ਱" ǗȗǪǮভࢪǨȜȏ  ҩ଻ࢷЭ
  11. SUPINF Inc. // twitter.com/toricls ǗȗǪǮڪɨƛǫȎǴȎȜȆǫȏ ҩ଻ҥ਱ ▶︎ ௰ƶƈƌű"MAICPLjȅȜǜ ▶︎ ऺʡƄƌű!.3ȅȆȎʎࣄಊ

    ▶︎ ࢷЭрٵƘƵƸdžǻȎǕȜǛȋȗƛ୸ҥʱ ▶︎ ȂNJȗǬƆƸǫLJȐǓǬȎ ▶︎ ˨್ƆƸȁȜǬ ▶︎ ǗȗǪǮƛȱƔ௰ƶƈƸǻȑǟǝƛҩ଻ǗȂȗǭřƗƖƗƖ ƖǀƗǗȗǪǮভࢪǨȜȏƿ ʎƐƓƯƨƩΝƅ ƀƛҥ਱ƕDockerLjȅȜǜŹ ůƹƝҞ˦ƘΝƅǗȗǪǮƿʈԽƔƯ ௲̿ƔźƸ
  12. SUPINF Inc. // twitter.com/toricls ǗȗǪǮڪɨƛǫȎǴȎȜȆǫȏ ǗȗǪǮভࢪǨȜȏਯƛǫǻȑLjȆǫȏ Docker njȗǜȗ ΤʔδΣϯτత Կ͔

    ȊȜǚȜŸƶƛ APIǗȜȏƿ ΃žɥžƸ ȂDZȜǜȇȜࣶƗʈŸ 1. "࣮ߦఆٛ"Λ࣮ߦʂ 3. ࢲͳʹ͔࢓ࣄ͋Γ·͢ʁ 2. ͸ʔ͍଴ͬͯͯͶ 4. ͜ͷ࣮ߦఆٛΑΖ͘͠ 5. ͜ͷΠϝʔδ͖࣋ͬͯͯ 6. docker pull 7. ͜Μͳײ͡Ͱ run ͯ͠ 8. runʂ ǿǝǬ Q. Ͳ͏Αʁ 9. ΦοέʔͰ͢ A. ॲཧதͰ͢ʔ 10. Ͳ͏Αʁ 11. ૸ͬͯ·ʔ͢ 0. "࣮ߦఆٛ"Λొ࿥ʂ
  13. SUPINF Inc. // twitter.com/toricls ǗȗǪǮŹࣳМƆƸ̣ƛLjȗǹȍȆǫȏ Java App A Java App

    B Rails App A Nginx Name: Java A Name: Java B Name: Rails A ϗετ
  14. SUPINF Inc. // twitter.com/toricls ǗȗǪǮŹࣳМƆƸ̣ƛLjȗǹȍȆǫȏ Java App A Java App

    B Rails App A Nginx Name: Java A Name: Java B Name: Rails A Auto-Scaled :D Rails App A Nginx Name: Rails A ϗετ
  15. SUPINF Inc. // twitter.com/toricls ǗȗǪǮڪɨƛLjȗǹȍȆǫȏ Rails App A Nginx Auto-Scaled

    :D Rails App A Nginx Java App A Java App B Name: Instance Name: Instance ϗετ
  16. SUPINF Inc. // twitter.com/toricls ϗετ ǗȗǪǮڪɨƛLjȗǹȍȆǫȏ Rails App A Nginx

    Rails App A Nginx Java App A Name: Instance Name: Instance Out of Memory :x
  17. SUPINF Inc. // twitter.com/toricls ϗετ Restarted :D ǗȗǪǮڪɨƛLjȗǹȍȆǫȏ Rails App

    A Nginx Rails App A Nginx Java App A Java App B Name: Instance Name: Instance
  18. SUPINF Inc. // twitter.com/toricls ǗȗǪǮڪɨƛLjȗǹȍȆǫȏ ǓȍǝǣȜ Cluster-Name: Some Project ෳ਺ͷϗετͷू߹

    ҩ଻ҥ਱ƔǗȗǪǮŹքୟƗCPUƱȅȆȎƿ ڞुƆƸƀƕƘƵƷř ţɆ৙࢜ŤƕűųȅǬȎǓǝƔ ȎǡȜǝƛǝǕȜȎȗǔŹΏ੧ƘƗƐƌ
  19. SUPINF Inc. // twitter.com/toricls ǥȜȄʇ̛ǫȎǴȎȜ ▶︎ ǻȑǜNjǓǬƘډƄż̲ƼƐƌ್ࣲਾŹୟƆƸڪ೐ƕǗǝǬƿۋӑ͎ƆƸ ▶︎ ȑȜǏȏ್ࣲࢷЭƛݙ঵ŹҞ˦ƘƯƄżƜřƨƩ ઈ͎̿ƂƹƓűƸ

    ▶︎ ൰ƛƵųƘ೉ű׮ഭۆƿȃǝƗżҩ଻ƄƗűƕ̿ŸƗűdžǻȎǕȜǛȋȗƜřш؃ƛМΙʓґȍLjǺȍȎƱȃǭȏNJNjdžƛۅډŹǥȜȄȅȗ ǴȜŸƶօ౞ƂƹřƖǀƖǀ೨ੳ͎ƄƓűż ▶︎ ৻ৼࣶǫǻȑLjٵ̐řٵڪ೐ͣʂƔƛǫǻȑLj ƿ଻ŵƸʇ̛ƘƆƸ ▶︎ ৻ৼࣶƘǫǻȑLjƿ଻ųƌƮƘƜřǫǻȑLjŹઈ͎̿ƂƹƓűƸƀƕƕřǫǻȑLjƘύ഻ŹůƐƌƕźƘҜփƄƓשƈƸƀƕŹಈୟ ▶︎ ǗȜǭƿۆűƌۙɛŹۙࣘࢷЭƛǫǻȑLjƫƔ߲ż೑ƼƸ ▶︎ ǗȗǪǮƛ൭űȁȜǣǷȎǪLJƿࣁŸƆƕřքࡔࣶƘǗȜǭǽȜǝƥƛǥNjǧǓLjȗŸƶǫǻȑLjƫƔƛڪ೐ŹटਘƂƹƸ ▶︎ ್ࣲࢷЭƛǗȗǪǮŹƊƛƫƫۙࣘƔ̿żƄřƊųƗƸƵųƘdžǻȎǕȜǛȋȗƿʊƐƓűƸƜƇƗƛƔ ▶︎ LjȗǹȍnjȗǜǯdžƜǫǻȑLjƊƹઈʇƿ؇զƆƸƛƔƜƗżřʢഺ֕൭żઈ͎̿ƂƹƌǫǻȑLjڊ߆ƛݙ঵Ƙӊ֍ƆƸƦź ▶︎ ǫǻȑLjŹэٯƄƌƕźřрƗƯƛƿǫǻȑLjƄƓƄƫƐƌƕźƘƘƖųƱƐƓȎǴȜǬƆƸŸƕŸdžǻȎǕȜǛȋȗnjȗǜǯdžƕ͡ ̰ƄƓટűǵLjǻȍLjȗƿʊƸ ▶︎ űű"MAICPLjȅȜǜƛʊƷڊƿȟਊƘ਽ŵƓůſƓƯűűŸƯřLjȅȜǜʊƐƎưƐƓƯűűŸƯ ▶︎ Ɩƹƍž̵̰ƄƓƯύ഻ƜքƇ௲źƸ"ύ഻ƿ௲ƀƂƗűƌƮƛǥNjǧǓʇ̛ƱȏȜȏƿքୟɪȥƘƁƎưƁƎưƱƸ"ƀƕƵƷƯř"ύ഻Ź ࣲࣁƄƌƕźƘۋटƛȎȜǭǣLjȄƔʤބࡱƛdžǻȎǕȜǛȋȗƿǫǻȑLjƔźƸ"ƀƕƛڊŹٵ˒ʫಈୟƔƜƗŸƺųŸƕ
  20. SUPINF Inc. // twitter.com/toricls ▶︎ ǗȜǭǽȜǝŹǴȜǜȋȗভࢪǛǝǪȄƛভࢪȦƘůƸ ▶︎ ȑǔƜݢࠑ̰̌ƘΡż ▶︎ džǻȎǕȜǛȋȗƛ؜̿рۅƜͳ̡ƕƄƓࢷЭрٵƔࠀƆ

    ▶︎ ǫǻȑLj˝ƛࢷЭƘʓґƄƌ୸ҥʱƕǫǻȑLjƛǗȗǪǑǝǬƿΝƅ"୸ҥ"ƕƄƓভࢪƆƸƕնƔǶLjLJƐƓƗƸ ▶︎ CE0?GJQƛ୸ҥǹDžLjȏƔűųƕƀƺƛ"ۙࣘƍƐƌƶƀƛǫȜǣǽȜǝ"ƛۆźڊƜࡽҥƛǛȜȗƔƑƶżƗƸƪƵ ▶︎ ǴǧǓnjȗǭǙȜǷǝʓґǙȜǷǝř" ƕŸǑȇǧǛȉǝǬȐȜǜƕŸ ƿҴڠƘ̑ƷۊŵƶƹƸƵųƘҩ୎ƂƹƓűƸ ▶︎ ۙࣘ" عৼ˝ƿрŵƵųƕƄƌڪƘǷȏǭŸƶƱƷइƆƛƜ஗ƐƓűƸ ▶︎ ఻Ԣƛ0?GJQƛ୸ҥǹDžLjȏƛŷʊ߆Ƙչųƕř" عৼ˝рۅƛƌƮƘǗȜǭǽȜǝȎȁǜǬȎ Ƙрۅƿ̲ŵƸքୟŹࣲࣁƄƓƄƫų ▶︎ ţȎȎȜǝŤǝǪȜǜƔ" عৼ˝ƛࢷЭрٵƿۆźهŵřţҩ଻ŤǝǪȜǜƔdžǻȎǕȜǛȋȗƿ௰ƶƈƸƛŹۓƫƄűƕƜ֒űƫƈǀŸ ▶︎ ǿǝǬȂǛȗƘʈŸƿەմƄƗű ▶︎ ţǿǝǬƛ'.ƜƀƹƔ̿űƓűƸƜƇඵŤƬƌűƗƛƕŸřǿǝǬƘࡽҥƛǫLJȐǓǬȎǹDžLjȏŹਧűƓůƸƜƇඵƕŸ ▶︎ ǫLJǝǓƘǹDžLjȏƿΡź̌ƂƗű ▶︎ ݹƛȎǓnjǝǬŹ۪ƌƕźƘƊƛǹDžLjȏŹґϺƆƸƀƕƿەմƄƗű ▶︎ ୟƜǝǕȜȏdžNJǬƔźƸƵųƘʊƶƹƓűƸƕűųƀƕ ▶︎ ʓґȍLjǺȍȎŹǵǧǕȜǜভࢪǨȜȏƗƖƿʎƐƓLjȗǝǬȜȏƔźƸƵųƘƗƐƓűƸCE SLBJCP džǻȎǕȜǛȋȗ
  21. SUPINF Inc. // twitter.com/toricls ▶︎ ್ࣲࢷЭƕۙࣘࢷЭƛԎࣙŹӒƗű ▶︎ CE್ࣲࢷЭƜ1/*GRCƍžƖۙࣘƜ.MQREPC1/*ƬƌűƗԎࣙƜdžǏȗ ▶︎ ௲̿ఽԽŹఽű

    ▶︎ ௲̿ڪƘȆȎȆȎ̅ࢪƿƱƸƵųƗƛƜ౞žƌű" ƛȂLjǔȐȜǛȋȗƕŸƜƊƯƊƯ௲̿̅ࢪƔƜƗűQCCǥȜȄʇ̛ඹǫȎǴȎȜ  ▶︎ ǛǔǮȏ1'%2#0+ƕŸ ƿ΃ž΂ƐƓƎưǀƕǔȐȜǝǹȏƘ৮ɅƔźƸ ▶︎ ઈఄƛݮ੧ƿȁȜǬƿ఻ƅƓ˨್ƆƸ džǻȎǕȜǛȋȗ
  22. SUPINF Inc. // twitter.com/toricls ోࣄ ▶︎ ǗȗǪǮƛҩ଻ভࢪŹƔźƓűƸ ▶︎ ǨȜȏƜѝźƗƯƛƿʎŵƝűűƕ֒ų ▶︎

    51ȊȜǚȜƛМΙřȂǝǣȜDzȜǭਯƛভࢪǗǝǬƿױƐƓƔƯ#!1ɪуƛ౛؀੕ƿ਽ŵƸƌƮƘƜƊƹई֊ƛࢪࣇŹքୟ ▶︎ ভࢪǣǝǓƯҩ೶Ƙ௰ƶƈƸ"MAICPLjȅȜǜƕΝƅƯƛƿʎƐƓ଻ų ▶︎ ǗȜǭǽȜǝř୸ҥʱƗƖŹ˦ƓΝƅƍŹřǗȗǪǮƿ௰ƶƈƸڪƛǗȂȗǭƍž౐ųࣶƗ ▶︎ džǻȎǕȜǛȋȗҩ଻Ź@SLBJCCVCAP?GJQQƔř" ȂLjǔȐǛȜǛȋȗŹ@SLBJCCVCAP?GJQB@KGEP?RCƬƌűƗ ▶︎ ȅǬȎǓǝƛ΀ഁƿ଻ųnjȜǜNjȗǬƯǗȗǪǮƔƱƹƸƕűƺűƺҊƄűCE"?R?BME +?AICPCJ ▶︎ ȑǔ΀ഁ ▶︎ ǗȗǪǮƛկ̫Ɯ௰ƐƓűƸǻȑǟǝƛݢࠑ̰̌ƿƖƀŸƘǝǬȎȜȃȗǔƆƸƕƀƺƫƔ ▶︎ Ɗƛ˝ƛௐ́Ɯ̘ƛdžǻȎǕȜǛȋȗ?UQJMEQ $JSCLRBƘ௉ƼƈƸ  ▶︎ ƖƀƔǗȗǪǮŹ̿űƓűƸŸƼŸƶƗűƀƕƿ̣لƘోࣄ୸୯ƆƸƀƕƿ୹ҴƆƸ ▶︎ ƖƀƔ̿żŸƼŸƶƗűƀƕƿ୹ҴƔźƸ ▶︎ ƖƀƔƯ̿ŸƈƸ ▶︎ ೷ҰࣲࣁڪƛռڔƘୟƆƸȎȜǭǣLjȄƿटਘƔźƸ ▶︎ ƼȜű
  23. SUPINF Inc. // twitter.com/toricls ోࣄ ▶︎ !'!"ඵ৻ৼࣶǫȎǴȎȜඵƱƶƗűƛǤȅǠǧǣLj ▶︎ !.3ȅȆȎƛ̫ƷզƓƕŸƿƎưǀƕƱƐƓř׆ƫƄƱŸƗǗȗǪǮƿ̿ŸƆ ▶︎

    ƀƀƛ̫ƷզƓƿƎưǀƕƱƹƓƗűƕǗȗǪǮƛ̙ࣄƘƵƸǗǝǬ̹࢜Źۋш͎ƔźƗű ▶︎ ƊƯƊƯΝƅǿǝǬƔ̿űƓűƸǗȗǪǮƂǀƌƎƘƕƐƓయֳ ▶︎ "MAICPnjȗǜȗƛǻȑǟǝઈʇƯः୤Ӈ௃ǗȗǪǮভࢪǨȜȏƛnjȜǜNjȗǬŹȟਊƘ̿űƓűƸМΙƜƊƹƯः୤ƄƌڊŹƬǀƗԬƈ  ▶︎ %MJ?LEƔۆŸƹƌdžǻȎƛƵųƘͣȟƛǴLjǮȎƔ̿ʊƆƸdžǻȎǕȜǛȋȗƔƯřǗȗǪǮ͎ƄƓǫǻȑLjƆƸ ▶︎ SGJB 1FGN 0SLƿɤƛdžǻȎǕȜǛȋȗƕ˪఻୭கȆǫȏ Ɣ଻ŵƸƀƕƘƵƸోࣄǗǝǬƛʃ߾ ▶︎ ҢٰதɇŹ௲źƸƛƔůǀƫƷ߲żƜ୬ƹƗű