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

docker_간단_가이드.pdf

raccoony
November 18, 2013
120

 docker_간단_가이드.pdf

raccoony

November 18, 2013
Tweet

Transcript

  1. docker Docker? pack, ship and run any application as a

    lightweight container (http://docker.io) গ೒ܻா੉࣌ ҳزਸ ਤೠ ੌઙ੄ (Ѻܻػ) о࢚ ജ҃ਸ ٜ݅ ࣻ ੓ח بҳ
  2. docker Requirements if osx: open http://downloads.vagrantup.com/ Vagrant : о࢚ ജ҃

    (with VirtualBox / Parallels / VMware Fusion ...) - ৵ Vagrant? dockerо ֿܻझী'݅' ઓ੤ೞח lxcۄח ӝמ ਸ ࢎਊೞӝ ٸޙী...
  3. docker Docker ࢸ஖ • ਋࠙ై (≥13.04 64bit) o http://docs.docker.io/en/latest/installation/ubuntulinux/ #ubuntu-raring

    • ਋࠙ై (≤12.04 64bit) o http://docs.docker.io/en/latest/installation/ubuntulinux/ #ubuntu-precise • ݓ ֿܻझ (with Vagrant) local:~$ git clone https://github.com/dotcloud/docker.git local:~$ cd docker local:~/docker$ vagrant up
  4. docker vagrant:~$ docker pull ubuntu vagrant:~$ docker run -i -t

    ubuntu /bin/bash root:~$ Docker ࢎਊ (with ֢о׮) 2/3
  5. docker vagrant:~$ docker pull ubuntu vagrant:~$ docker run -i -t

    ubuntu /bin/bash root:~$ Docker ࢎਊ (with ֢о׮) 2/3 Precise64 base Ubuntu + docker Ѣ੄ ইޖ Ѫب হ਺.
  6. docker vagrant:~$ docker pull ubuntu vagrant:~$ docker run -i -t

    ubuntu /bin/bash root:~$ Docker ࢎਊ (with ֢о׮) 2/3 Precise64 base Ubuntu + docker Ѣ੄ ইޖ Ѫب হ਺. ۽ஸ Vagrant Docker
  7. docker Docker ࢎਊ (with ֢о׮) 2/3 vagrant:~$ docker pull ubuntu

    vagrant:~$ docker run -i -t ubuntu /bin/bash root@imageid:/# apt-get update root@imageid:/# apt-get install … (git, pip ١) root@imageid:/# git clone git://proj.... root@imageid:/proj# pip install -r requirements.txt root@imageid:/proj# python manage.py syncdb root@imageid:/proj# python manage.py collectstatic
  8. docker Docker ࢎਊ (with ֢о׮) 3/3 root@imageid:/proj# exit vagrant:~$ docker

    commit imageid name vagrant:~$ docker run -i -t -d -p 8080:8080 name \ uwsgi --ini=/production/uwsgi.ini ۽ஸ о࢚ ജ҃ Vagrant ਢ ࢲߡ Docker
  9. docker ՘? ੉޷૑ ݅٘ח ؘ ؀ۚ (੊ࣼ೧૑ݶ) 30࠙… ੉ ੉޷૑ܳ

    ec2ীࢲب جܻҊ र׮ݶ? ec2ী ੽ࣘೞৈ খ੄ җ੿ਸ ߈ࠂೞࣁਃ… docker ৵ ॄ?!
  10. docker Dockerfile ࢸ੿ 1/3 <౵ੌ: notice/Dockerfile> FROM kencochrane/django-docker RUN apt-get

    update RUN apt-get install -y libmysqlclient-dev libldap2-dev libsasl2-dev libssl-dev RUN pip install uwsgi ADD ./requirements.txt /home/ WORKDIR /home/ RUN pip install -r requirements.txt ADD . /home EXPOSE 8080 CMD ["uwsgi", "--ini", "/home/production/uwsgi.ini"] vagrant:~$ docker build -t=name .
  11. docker Dockerfile ࢸ੿ 2/3 FROM kencochrane/django-docker : ޷ܻ ٜ݅য ك

    ӝࠄ ੉޷૑ܳ ੤ഝਊೡ ࣻ ੓׮. RUN apt-get update : build җ੿ীࢲ ೧׼ ݺ۸ਸ प೯ೣ. ࠁా ੄ઓࢿ ಁః૑ ࢸ஖. ADD . /home : docker ৻ࠗ੄ . ٣۩ఠܻܳ » docker ղࠗ੄ /homeਵ۽ ࠂࢎ
  12. docker Dockerfile ࢸ੿ 2/3 FROM kencochrane/django-docker : ޷ܻ ٜ݅য ك

    ӝࠄ ੉޷૑ܳ ੤ഝਊೡ ࣻ ੓׮. RUN apt-get update : build җ੿ীࢲ ೧׼ ݺ۸ਸ प೯ೣ. ࠁా ੄ઓࢿ ಁః૑ ࢸ஖. ADD . /home : docker ৻ࠗ੄ . ٣۩ఠܻܳ » docker ղࠗ੄ /homeਵ۽ ࠂࢎ
  13. docker Dockerfile ࢸ੿ 2/3 FROM kencochrane/django-docker : ޷ܻ ٜ݅য ك

    ӝࠄ ੉޷૑ܳ ੤ഝਊೡ ࣻ ੓׮. RUN apt-get update : build җ੿ীࢲ ೧׼ ݺ۸ਸ प೯ೣ. ࠁా ੄ઓࢿ ಁః૑ ࢸ஖. ADD . /home : docker ৻ࠗ੄ . ٣۩ఠܻܳ » docker ղࠗ੄ /homeਵ۽ ࠂࢎ Ubuntu
  14. docker Dockerfile ࢸ੿ 2/3 FROM kencochrane/django-docker : ޷ܻ ٜ݅য ك

    ӝࠄ ੉޷૑ܳ ੤ഝਊೡ ࣻ ੓׮. RUN apt-get update : build җ੿ীࢲ ೧׼ ݺ۸ਸ प೯ೣ. ࠁా ੄ઓࢿ ಁః૑ ࢸ஖. ADD . /home : docker ৻ࠗ੄ . ٣۩ఠܻܳ » docker ղࠗ੄ /homeਵ۽ ࠂࢎ Ubuntu Python 2.7
  15. docker Dockerfile ࢸ੿ 2/3 FROM kencochrane/django-docker : ޷ܻ ٜ݅য ك

    ӝࠄ ੉޷૑ܳ ੤ഝਊೡ ࣻ ੓׮. RUN apt-get update : build җ੿ীࢲ ೧׼ ݺ۸ਸ प೯ೣ. ࠁా ੄ઓࢿ ಁః૑ ࢸ஖. ADD . /home : docker ৻ࠗ੄ . ٣۩ఠܻܳ » docker ղࠗ੄ /homeਵ۽ ࠂࢎ Ubuntu Python 2.7 Django 1.6
  16. docker Dockerfile ࢸ੿ 2/3 FROM kencochrane/django-docker : ޷ܻ ٜ݅য ك

    ӝࠄ ੉޷૑ܳ ੤ഝਊೡ ࣻ ੓׮. RUN apt-get update : build җ੿ীࢲ ೧׼ ݺ۸ਸ प೯ೣ. ࠁా ੄ઓࢿ ಁః૑ ࢸ஖. ADD . /home : docker ৻ࠗ੄ . ٣۩ఠܻܳ » docker ղࠗ੄ /homeਵ۽ ࠂࢎ Ubuntu Python 2.7 Django 1.6 app 1
  17. docker Dockerfile ࢸ੿ 2/3 FROM kencochrane/django-docker : ޷ܻ ٜ݅য ك

    ӝࠄ ੉޷૑ܳ ੤ഝਊೡ ࣻ ੓׮. RUN apt-get update : build җ੿ীࢲ ೧׼ ݺ۸ਸ प೯ೣ. ࠁా ੄ઓࢿ ಁః૑ ࢸ஖. ADD . /home : docker ৻ࠗ੄ . ٣۩ఠܻܳ » docker ղࠗ੄ /homeਵ۽ ࠂࢎ Ubuntu Python 2.7 Django 1.6 app 1 app 2
  18. docker Dockerfile ࢸ੿ 2/3 FROM kencochrane/django-docker : ޷ܻ ٜ݅য ك

    ӝࠄ ੉޷૑ܳ ੤ഝਊೡ ࣻ ੓׮. RUN apt-get update : build җ੿ীࢲ ೧׼ ݺ۸ਸ प೯ೣ. ࠁా ੄ઓࢿ ಁః૑ ࢸ஖. ADD . /home : docker ৻ࠗ੄ . ٣۩ఠܻܳ » docker ղࠗ੄ /homeਵ۽ ࠂࢎ Ubuntu Python 2.7 Django 1.6 app 1 app 2 flask 0.10 app 3
  19. docker ੤ഝਊೡ ࣻ ੓ח ੉޷૑ٜ • https://index.docker.ioীࢲ Ѩ࢝ • mbkan/lamp

    o CentOS o apache, mysql, php, phpmyadmin • kencochrane/django-docker o ubuntu 12.10 o django ҳزী ೙ਃೠ ӝࠄ ࢎ೦ਸ ࢸ஖೧ ك ੉޷૑ • ruby, perl ١ ׮নೠ ജ҃੉ ઓ੤ೣ o ա݅੄ ੉޷૑ܳ ٜ݅ ࣻب ੓਺
  20. docker Dockerfile ࢸ੿ 2/3 FROM kencochrane/django-docker : ޷ܻ ٜ݅য ك

    ӝࠄ ੉޷૑ܳ ੤ഝਊೡ ࣻ ੓׮. RUN apt-get update : build җ੿ীࢲ ೧׼ ݺ۸ਸ प೯ೣ. ࠁా ੄ઓࢿ ಁః૑ ࢸ஖. ADD . /home : docker ৻ࠗ੄ . ٣۩ఠܻܳ » docker ղࠗ੄ /homeਵ۽ ࠂࢎ
  21. docker Dockerfile ࢸ੿ 3/3 WORKDIR /home : ੉റ੄ ݺ۸যо प೯ؼ

    ٣۩ఠܻ ૑੿ EXPOSE 8080 : ղࠗ੄ 8080 ನ౟ܳ ৌয م CMD ["uwsgi", "--ini", "/home/production/uwsgi.ini"] : docker run imageid ೮ਸ ٸ, ੉ ݺ۸੉ प೯ؽ. Dockerfile ղীࢲ ೞա݅!) (ENTRYPOINTب ࠺तೞա run ݺ۸ ٍ੄ ੋ੗ܳ ߉਺. ৉द ೞա݅ оמ)
  22. docker ֢о׮ Docker৬ Dockerfile ࠺Ү ֢о׮ Docker Dockerfile 10+aѐ 10ѐ

    30࠙ (੊ࣼ೧૑ݶ) 10࠙ पࣻ оמ पࣻ ઴যٝ
  23. docker ֢о׮ Docker৬ Dockerfile ࠺Ү EC2 Docker EC2 Docker -

    docker ੉޷૑ ࢤࢿ - docker ੉޷૑ ੽ࣘ - ੄ઓࢿ(apt-get) ࢸ஖ - ୭न ࣗझ௏٘ ߉ӝ - ੄ઓࢿ(pip) ࢸ஖ - docker run - docker build - docker run
  24. docker docker-registry Ӕؘ ۽ஸীࢲ ݅ٚ ੉޷૑ܳ ec2ী যڌѱ ֍ભ? ec2ীࢲ

    ૒੽ buildೞࣁਃ… oTL • docker-registry o vagrant:~$ docker push raccoony/name o ec2:~$ docker pull raccoony/name o ec2:~$ docker run -i -t -d -p 8080:8080 … https://index.docker.ioী оੑೠ ID ੉޷૑ ੉ܴ (݋؀۽)
  25. docker അ੤ө૑ ੿ܻ ֢о׮ Docker Dockerfile docker-registry 10+aѐ 10ѐ 7ѐ

    30࠙ (੊ࣼ೧૑ݶ) 10࠙ 4࠙ पࣻ оמ पࣻ ઴যٝ पࣻ ࠛоמ (য়ఋ݅ ઑब)
  26. docker Dockerfileҗ docker-registry ࠺Ү EC2 Docker EC2 Docker ۽ஸীࢲ ѐߊ

    റ - docker build - docker run ੜ غݶ - ec2 ੽ࣘ - docker build - docker run ۽ஸীࢲ ѐߊ റ - docker build - docker run ੜ غݶ - docker push - ec2 ੽ࣘ - docker pull - docker run ۽ஸ Vagrant ۽ஸ Vagrant ઺ࠂ (=աࢁ׮) ઺ࠂ ࢏ઁ (=જ׮)
  27. docker ࢲ࠺झ ߓನ җ੿ ਃড local:~$ vagrant up local:~$ vagrant

    ssh vagrant:~$ git pull vagrant:~$ docker build -t=name . vagrant:~$ docker push raccoony/name ec2:~$ docker pull raccoony/name ec2:~$ docker run -i -t -d -p 8080:8080 name
  28. docker അ੤ө૑ ו՛ ੢ױ੼ • ੢੼ o Dockerfile݅ ੜ ٜ݅য

    فݶ, ࢲ࠺झ ৢܻҊ ղܻח ੌ੉ औ׮ o ࢲ࠺झ ৢܻ۰Ҋ ࢲߡܳ ߓ਎ ೙ਃо হ׮(؀न docker ݺ۸ਸ ߓਕ...) • ױ੼ o docker ղࠗী ऺ੉ח ۽Ӓܳ ࠁӝо ൨ٜ׮(઺ਃ ۽Ӓח दझమ ৻ࠗ۽) o ୡӝ ѐ֛ ੟ӝо ઑӘ ൨ٜ׮(ৈӝࢲ ࢸݺೞ૑ ঋ਷ image৬ container੄ ҙ҅) o build ݺ۸ী दр੉ ખ Ѧܻחؘ… -> dokku, deis ١ਵ۽ ೧Ѿ
  29. docker dokku • dokku o docker ੹ਊ git ੷੢ࣗ +

    ੗ز ࠽٘ o local:~$ git remote add dokku.raccoony.kr/proj dokku o local:~$ git push dokku master o ঌইࢲ ࠽٘غҊ, ੉޷૑ ੷੢ࣗী ١۾غҊ, ࢜ ੉޷૑о प೯ؽ पઁ ࢸ੿ب ׮ ೮חؘ… - ݻݻ ಁః૑ ࢸ஖ पಁ - buildpack੉ۄח ੌઙ੄ ֿܻझ ੉޷૑ীࢲ ࠽٘ - ӝઓ buildpackਵ۽ উ غפ, ա݅੄ buildpackਸ ٜ݅ө? - buildpackਸ ݅٘ח झ௼݀౟ = buildstep… ই... ૑ଢ଼׮… - (઱੄) ױੌ ࢲߡ݅ ૑ਗ
  30. docker deis.io • ݣ౭ ࢲߡ ૑ਗغח dokku э਷ ֗ࢳ o

    Ӓ۞ա ࢎਊ೧ࠁ૑ ঋও਺(૑୛ࢲ).
  31. docker dokku بੑ റ੄ ݽण EC2 Docker EC2 Docker ۽ஸীࢲ

    ѐߊ റ - docker build - docker run ੜ غݶ - docker push - ec2 ੽ࣘ - docker pull - docker run ۽ஸীࢲ ѐߊ റ ੜ غݶ - git push ঌইࢲ সؘ੉౟ ۽ஸ Vagrant ۽ஸ Vagrant
  32. docker dokku بੑ റ ࠺Ү ֢о׮ Docker Dockerfile docker- registry

    deis 10+aѐ 10ѐ 7ѐ 1ѐ (push) 30࠙ (੊ࣼ೧૑ݶ) 10࠙ 4࠙ 1࠙ पࣻ оמ पࣻ ࠛоמ (Ѣ੄) पࣻ ࠛоמ (য়ఋ݅ ઑब) ੗زച ୌҴ!
  33. docker Docker ݺ۸ рۚ ੿ܻ 1/3 • docker run -i

    -t -d -p 0:0 id ݺ۸য o -i :Keep stdin open even if not attached o -t :Allocate a pseudo-tty o -d :ؘހ ഋక۽ प೯ o -p : ನ౟ ನਕ٬ (৻ࠗ ನ౟ -> ղࠗ ನ౟) o id : ੉޷૑ idա ੉ܴ o ݺ۸য : Dockerfileী ੓ח CMD ؀न प೯ೞҊ र਷ ݺ۸য (഑਷ ENTRYPOINTী ૑੿ೞ۰ח ੋ੗)
  34. docker Docker ݺ۸ рۚ ੿ܻ 2/3 • docker build -t=name

    . o name : ੷੢ೞ۰ח ੉޷૑ী ࠢੌ ੉ܴ o . : ࠽٘ೞ۰ח ؀࢚ ٣۩ఠܻ • docker commit ab12cd34 name o ab12cd34 : ੉޷૑੄ Ҋਬ id o name : ૑੿ೞҊ र਷ ੉ܴ
  35. docker Docker ݺ۸ рۚ ੿ܻ 3/3 • docker images o

    ੉޷૑ ݾ۾ਸ ࠁৈષ • docker ps o അ੤ प೯ ઺ੋ ੉޷૑ ݾ۾ਸ ࠁৈષ(ps৬ ࠺त) • docker kill id (or name) o प೯ ઺ੋ ੉޷૑ • docker rmi id (or name) o ೧׼ ੉޷૑ܳ ࢏ઁ
  36. docker ؊ ੍ਸѢܻ • docker.io੄ ѐߊ੗ kencocrane੄ Docker Guide Book

    o http://kencochrane.net/blog/2013/08/the-docker-guidebook/ • docker ҕध ޙࢲ o http://docs.docker.io/en/latest/ • docker book (૘೙ ઺) o http://dockerbook.com/