Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
GDGி㒔䚷2014ᖺᛀ䜜ຮᙉ఍ LT 
Docker䛿䛨䜑䜎䛧䛯䚹 
GDG⚄ᡞ䚷㔝⏣ᝅᚿ
䛹䛳䛛䞊䠛䛠䛳䛠䛳䛶䜏䛯 
Docker䛿䝋䝣䝖䜴䜵䜰䝁䞁䝔䝘ෆ䛾䜰䝥䝸䜿䞊䝅䝵䞁䛾䝕䝥䝻䜲䝯䞁䝖䜢⮬ື໬䛩䜛 
䜸䞊䝥䞁䝋䞊䝇䝋䝣䝖䜴䜵䜰䛷䛒䜛䚹 
Linux䜹䞊䝛䝹䛻䛚䛡䜛LXC䛸࿧䜀䜜䜛Linux䝁䞁䝔䝘ᢏ⾡䛸Aufs䛸䛔䛖≉Ṧ䛺䝣䜯䜲...
䛹䛳䛛䞊䛳䛶 
䛺䜛䜋䛹䚹 
䜘䛟䜟䛛䜙䜣䚹 
䛷䜒䚸䠍䛴䛰䛡㔜せ䛺䛣䛸䛜䚹
䛹䛳䛛䞊䛿 
Go䛷ฟ᮶䛶䛔䜎䛩䚹
኱஦䛺䛣䛸䛺䛾䛷䜒䛖୍ᗘ 
Go䛷 
ฟ᮶䛶䛔䜎䛩䚹
䛱䜗䛳䛸ჶ䜏○䛟䛸 
䞉䝁䞁䝔䝘䛸䛔䛖௬᝿⎔ቃ䛜స䜜䜛 
䞉VMWare䛸䛛䛾௬᝿䝬䝅䞁䛸㐪䛳䛶䚸䝩䝇䝖OS䛾 
䝇䝨䝑䜽䛜䜋䜌㐺⏝䛷䛝䜛 
䞉䝗䝷䜲䝤ᐜ㔞䜒䛭䜣䛺䛻㣗䜟䛺䛔 
䞉䝁䞁䝔䝘䛻౑䛘䜛䛾䛿x64䛾Linux䛰䛡 
䞉DockerHu...
⡆༢䛻ゝ䛖䛸 
䛸䛶䜒䝃䜽䝃䜽ື䛔䛶䛟䜜䛶 
䛔䛳䜁䛔⎔ቃస䛳䛶䜒OK䛺 
౽฼䛷䛔䛔䜔䛴䛰䜘
䛺䜣䛷䛹䛳䛛䞊䠛 
௒䜎䛷௬᝿䝬䝅䞁䜢౑䛳䛶䛯 
䞉Ⓨ⾲㈨ᩱస䜛䛯䜑䛾᳨ド⎔ቃ 
䞉㛤Ⓨ⎔ቃ䜢䜟䛡䛶䛚䛟䛯䜑 
䞉᪂䛧䛔OS䜢౑䛳䛶䜏䛯䛔ሙྜ䚸୙ලྜ䛰䜙䛡䛷䜒 
స䜚ᤞ䛶ฟ᮶䜛䛯䜑 
䞉᪂䛧䛔⎔ቃ䛷ᚰᶵ୍㌿
䛺䜣䛷䛹䛳䛛䞊䠛 
ၥ㢟Ⅼ䜒䛔䛟䛴䛛䛒䛳䛶ᅔ䛳䛶䛯 
䞉ᐜ㔞㣗䛖䛛䜙䛭䜣䛺䛻䛔䛳䜁䛔స䛳䛶ಖᣢ䛷䛝䛺 
䛔 
䞉䛒䜛⛬ᗘ䛾ືస䜢䛥䛫䜛䛯䜑䛻䛿䚸䝩䝇䝖䝬䝅䞁 
䛾䝁䜰䛸䛛䝯䝰䝸䛸䛛⤖ᵓ๭䜚ᙜ䛶䜛ᚲせ䛜䛒䜛
䛺䜣䛷䛹䛳䛛䞊䠛 
䛭䜣䛺䛸䛣䜝䛻 
Docker䛜䟿
䛹䛳䛛䞊䜅䛑䛔䜛 
Dockerfile䛿䝁䞁䝔䝘䛾సᡂ䛸䚸సᡂ䛧䛯䝁䞁䝔䝘 
ୖ䛷ᐇ⾜䛧䛯䛔䝁䝬䞁䝗䜢ᐃ⩏䛩䜛䝣䜯䜲䝹䚹 
⎔ቃᵓ⠏䛷䝟䝑䜿䞊䝆䛾䜲䞁䝇䝖䞊䝹䛸䛛䚸䛚Ỵ䜎 
䜚䛾䝁䝬䞁䝗䜢ᐃ⩏䛧䛶䛚䛡䜀䚸సᡂ䛸䜲䞁䝇䝖䞊䝹 
䜢୍ᣓ䛷䜔䛳䛶䛟...
䛹䛳䛛䞊䜅䛑䛔䜛 
FROM ubuntu 
MAINTAINER scarviz <scarviz@gmail.com> 
# add work user 
RUN adduser gopher 
RUN echo "gopher:gophe...
䛹䛳䛛䞊䜅䛑䛔䜛䛷GAE/Go 
GAE/Go⎔ቃ䜢సᡂ䛩䜛Dockerfile䜢స䛳䛶䜏䛯 
$ wget http://goo.gl/Dsh8zX -O Dockerfile 
䈜Dockerfile䛿䛂Dockerfile䛃䛸䛔䛖䝣䜯䜲䝹...
䛹䛳䛛䞊䜅䛑䛔䜛䛷GAE/Go 
Dockerfile䛷䝁䞁䝔䝘䛾సᡂ 
$ sudo docker build -t gopher/u1404 . 
䈜䛂gopher/u1404䛃䛿௵ព䛾䜲䝯䞊䝆ྡ 
䚷䛂.䛃䛿Dockerfile䛾᱁⣡䝕䜱...
䛹䛳䛛䞊䜅䛑䛔䜛䛷GAE/Go 
䝁䞁䝔䝘䜢సᡂ䛧䚸㉳ື䛩䜛 
$ sudo docker run -i -t gopher/u1404 /bin/bash 
䈜ඹ᭷䝕䜱䝺䜽䝖䝸䜢సᡂ䛩䜛ሙྜ䛿-v䜸䝥䝅䝵䞁 
$ sudo docker ru...
䛹䛳䛛䞊䜅䛑䛔䜛䛷GAE/Go 
䝩䝇䝖OS䛷䜰䜽䝉䝇䛷䛝䜛䜘䛖䛻ᐇ⾜ 
$ dev_appserver.py ./ --port 8080 --host 0.0.0.0 
䝩䝇䝖OS䛷䝤䝷䜴䝄䛛䜙 
䛂http://(IP䜰䝗䝺䝇):8080...
䛹䛳䛛䞊䜅䛑䛔䜛䛷GAE/Go 
Demo The Go gopher@Renee French. http://goo.gl/q6msPI CC BY 3.0
䛹䛳䛛䞊䛾⤂௓䛷䛧䛯 
䛤Ύ⫈ 
䛒䜚䛜䛸䛖䛤䛦䛔䜎䛧䛯
䜅䜝䛟䚷䛹䛳䛛䞊䛾౑䛔᪉ 
⎔ቃ 
䚷Ubuntu14.04 x64 
䚷䈜VMWarePlayer 6䛷ືస
䛹䛳䛛䞊䛾౑䛔᪉ 
Docker䜢䜲䞁䝇䝖䞊䝹 
$ sudo apt-get update 
$ sudo apt-get install docker.io
䛹䛳䛛䞊䛾౑䛔᪉ 
Docker䝁䝬䞁䝗䜢᭷ຠ໬ 
$ source /etc/bash_completion.d/docker.io
䛹䛳䛛䞊䛾౑䛔᪉ 
Docker䝞䞊䝆䝵䞁☜ㄆ 
$ sudo docker --version
䛹䛳䛛䞊䛾౑䛔᪉ 
Docker䜲䝯䞊䝆䛾᳨⣴䚷(౛䠖Ubuntu᳨⣴) 
$ sudo docker search ubuntu 
Docker䜲䝯䞊䝆䜢ྲྀᚓ䚷(౛䠖Ubuntuྲྀᚓ) 
$ sudo docker pull ubuntu
䛹䛳䛛䞊䛾౑䛔᪉ 
ྲྀᚓ῭䜏Docker䜲䝯䞊䝆୍ぴ 
$ sudo docker images
䛹䛳䛛䞊䛾౑䛔᪉ 
Docker䝁䞁䝔䝘సᡂ(㉳ື) 
$ sudo docker run -i -t ubuntu /bin/bash 
䈜䛂ubuntu䛃䛿䜲䝯䞊䝆ྡ 
䚷䛂/bin/bash䛃䛿ᐇ⾜䝁䝬䞁䝗
䛹䛳䛛䞊䛾౑䛔᪉ 
Docker䝁䞁䝔䝘୍ぴ 
$ sudo docker ps -a 
䈜㉳ື୰䛾䜒䛾䛾䜏䛺䜙-a䜸䝥䝅䝵䞁䛿୙せ
䛹䛳䛛䞊䛾౑䛔᪉ 
Docker䝁䞁䝔䝘䛾෌㉳ື 
$ sudo docker start (ID) 
$ sudo docker attach --sig-proxy=false (ID) 
䈜docker run䛿䝁䞁䝔䝘䜢᪂つసᡂ䛩䜛䛾䛷...
䛹䛳䛛䞊䛾౑䛔᪉ 
Docker䝁䞁䝔䝘䛾๐㝖䚷䈜ID䛿䝁䞁䝔䝘䛾ID 
$ sudo docker rm (ID) 
Docker䜲䝯䞊䝆䛾๐㝖䚷䈜ID䛿䜲䝯䞊䝆䛾ID 
$ sudo docker rmi (ID)
Upcoming SlideShare
Loading in …5
×

dockerはじめました。 GDG京都 2014年忘れ勉強会 LT

495 views

Published on

  • Be the first to comment

dockerはじめました。 GDG京都 2014年忘れ勉強会 LT

  1. 1. GDGி㒔䚷2014ᖺᛀ䜜ຮᙉ఍ LT Docker䛿䛨䜑䜎䛧䛯䚹 GDG⚄ᡞ䚷㔝⏣ᝅᚿ
  2. 2. 䛹䛳䛛䞊䠛䛠䛳䛠䛳䛶䜏䛯 Docker䛿䝋䝣䝖䜴䜵䜰䝁䞁䝔䝘ෆ䛾䜰䝥䝸䜿䞊䝅䝵䞁䛾䝕䝥䝻䜲䝯䞁䝖䜢⮬ື໬䛩䜛 䜸䞊䝥䞁䝋䞊䝇䝋䝣䝖䜴䜵䜰䛷䛒䜛䚹 Linux䜹䞊䝛䝹䛻䛚䛡䜛LXC䛸࿧䜀䜜䜛Linux䝁䞁䝔䝘ᢏ⾡䛸Aufs䛸䛔䛖≉Ṧ䛺䝣䜯䜲 䝹䝅䝇䝔䝮䜢฼⏝䛧䛶䝁䞁䝔䝘ᆺ䛾௬᝿໬䜢⾜䛖䚹VMware〇ရ䛺䛹䛾᏶඲௬᝿໬䜢 ⾜䛖䝝䜲䝟䞊䝞䜲䝄䞊ᆺ〇ရ䛸ẚ䜉䛶䚸䝕䜱䝇䜽౑⏝㔞䛿ᑡ䛺䛟䚸䜲䞁䝇䝍䞁䝇సᡂ䜔 䜲䞁䝇䝍䞁䝇㉳ື䛿㏿䛟䚸ᛶ⬟ຎ໬䛜䜋䛸䜣䛹䛺䛔䛸䛔䛖฼Ⅼ䜢ᣢ䛴䚹dockerfile䛸࿧ 䜀䜜䜛タᐃ䝣䜯䜲䝹䛛䜙䝁䞁䝔䝘䜲䝯䞊䝆䝣䜯䜲䝹䜢సᡂྍ⬟䛸䛔䛖≉ᛶ䜢ᣢ䛴䚹୍᪉ 䛷䚸䝁䞁䝔䝘OS䛸䛧䛶䛿䝩䝇䝖OS䛸ྠ䛨Linux䜹䞊䝛䝹䛧䛛ືస䛧䛺䛔䚹 ᘬ⏝䠖Docker - Wikipedia http://ja.wikipedia.org/wiki/Docker
  3. 3. 䛹䛳䛛䞊䛳䛶 䛺䜛䜋䛹䚹 䜘䛟䜟䛛䜙䜣䚹 䛷䜒䚸䠍䛴䛰䛡㔜せ䛺䛣䛸䛜䚹
  4. 4. 䛹䛳䛛䞊䛿 Go䛷ฟ᮶䛶䛔䜎䛩䚹
  5. 5. ኱஦䛺䛣䛸䛺䛾䛷䜒䛖୍ᗘ Go䛷 ฟ᮶䛶䛔䜎䛩䚹
  6. 6. 䛱䜗䛳䛸ჶ䜏○䛟䛸 䞉䝁䞁䝔䝘䛸䛔䛖௬᝿⎔ቃ䛜స䜜䜛 䞉VMWare䛸䛛䛾௬᝿䝬䝅䞁䛸㐪䛳䛶䚸䝩䝇䝖OS䛾 䝇䝨䝑䜽䛜䜋䜌㐺⏝䛷䛝䜛 䞉䝗䝷䜲䝤ᐜ㔞䜒䛭䜣䛺䛻㣗䜟䛺䛔 䞉䝁䞁䝔䝘䛻౑䛘䜛䛾䛿x64䛾Linux䛰䛡 䞉DockerHub䜔䚸Dockerfile䛷⡆༢䛻ඹ᭷䛷䛝䜛
  7. 7. ⡆༢䛻ゝ䛖䛸 䛸䛶䜒䝃䜽䝃䜽ື䛔䛶䛟䜜䛶 䛔䛳䜁䛔⎔ቃస䛳䛶䜒OK䛺 ౽฼䛷䛔䛔䜔䛴䛰䜘
  8. 8. 䛺䜣䛷䛹䛳䛛䞊䠛 ௒䜎䛷௬᝿䝬䝅䞁䜢౑䛳䛶䛯 䞉Ⓨ⾲㈨ᩱస䜛䛯䜑䛾᳨ド⎔ቃ 䞉㛤Ⓨ⎔ቃ䜢䜟䛡䛶䛚䛟䛯䜑 䞉᪂䛧䛔OS䜢౑䛳䛶䜏䛯䛔ሙྜ䚸୙ලྜ䛰䜙䛡䛷䜒 స䜚ᤞ䛶ฟ᮶䜛䛯䜑 䞉᪂䛧䛔⎔ቃ䛷ᚰᶵ୍㌿
  9. 9. 䛺䜣䛷䛹䛳䛛䞊䠛 ၥ㢟Ⅼ䜒䛔䛟䛴䛛䛒䛳䛶ᅔ䛳䛶䛯 䞉ᐜ㔞㣗䛖䛛䜙䛭䜣䛺䛻䛔䛳䜁䛔స䛳䛶ಖᣢ䛷䛝䛺 䛔 䞉䛒䜛⛬ᗘ䛾ືస䜢䛥䛫䜛䛯䜑䛻䛿䚸䝩䝇䝖䝬䝅䞁 䛾䝁䜰䛸䛛䝯䝰䝸䛸䛛⤖ᵓ๭䜚ᙜ䛶䜛ᚲせ䛜䛒䜛
  10. 10. 䛺䜣䛷䛹䛳䛛䞊䠛 䛭䜣䛺䛸䛣䜝䛻 Docker䛜䟿
  11. 11. 䛹䛳䛛䞊䜅䛑䛔䜛 Dockerfile䛿䝁䞁䝔䝘䛾సᡂ䛸䚸సᡂ䛧䛯䝁䞁䝔䝘 ୖ䛷ᐇ⾜䛧䛯䛔䝁䝬䞁䝗䜢ᐃ⩏䛩䜛䝣䜯䜲䝹䚹 ⎔ቃᵓ⠏䛷䝟䝑䜿䞊䝆䛾䜲䞁䝇䝖䞊䝹䛸䛛䚸䛚Ỵ䜎 䜚䛾䝁䝬䞁䝗䜢ᐃ⩏䛧䛶䛚䛡䜀䚸సᡂ䛸䜲䞁䝇䝖䞊䝹 䜢୍ᣓ䛷䜔䛳䛶䛟䜜䜛䚹」〇䜔ඹ᭷䛻౽฼䚹 ᐇ⾜䝁䝬䞁䝗䛾☜ㄆ⏝䛻䜒౑䛘䜛䚹
  12. 12. 䛹䛳䛛䞊䜅䛑䛔䜛 FROM ubuntu MAINTAINER scarviz <scarviz@gmail.com> # add work user RUN adduser gopher RUN echo "gopher:gopher" |chpasswd RUN gpasswd -a gopher sudo # install package RUN apt-get update RUN apt-get install -y vim wget unzip git mercurial python # change user USER gopher # work dir WORKDIR /home/gopher
  13. 13. 䛹䛳䛛䞊䜅䛑䛔䜛䛷GAE/Go GAE/Go⎔ቃ䜢సᡂ䛩䜛Dockerfile䜢స䛳䛶䜏䛯 $ wget http://goo.gl/Dsh8zX -O Dockerfile 䈜Dockerfile䛿䛂Dockerfile䛃䛸䛔䛖䝣䜯䜲䝹ྡ䛻䛩䜛
  14. 14. 䛹䛳䛛䞊䜅䛑䛔䜛䛷GAE/Go Dockerfile䛷䝁䞁䝔䝘䛾సᡂ $ sudo docker build -t gopher/u1404 . 䈜䛂gopher/u1404䛃䛿௵ព䛾䜲䝯䞊䝆ྡ 䚷䛂.䛃䛿Dockerfile䛾᱁⣡䝕䜱䝺䜽䝖䝸(౛䛿䜹䝺䞁䝖)
  15. 15. 䛹䛳䛛䞊䜅䛑䛔䜛䛷GAE/Go 䝁䞁䝔䝘䜢సᡂ䛧䚸㉳ື䛩䜛 $ sudo docker run -i -t gopher/u1404 /bin/bash 䈜ඹ᭷䝕䜱䝺䜽䝖䝸䜢సᡂ䛩䜛ሙྜ䛿-v䜸䝥䝅䝵䞁 $ sudo docker run -i -t -v (䝩䝇䝖䛾ඹ᭷dir):/home/gopher/share_gopher gopher/u1404 /bin/bash
  16. 16. 䛹䛳䛛䞊䜅䛑䛔䜛䛷GAE/Go 䝩䝇䝖OS䛷䜰䜽䝉䝇䛷䛝䜛䜘䛖䛻ᐇ⾜ $ dev_appserver.py ./ --port 8080 --host 0.0.0.0 䝩䝇䝖OS䛷䝤䝷䜴䝄䛛䜙 䛂http://(IP䜰䝗䝺䝇):8080䛃䛻䜰䜽䝉䝇䛩䜜䜀OK
  17. 17. 䛹䛳䛛䞊䜅䛑䛔䜛䛷GAE/Go Demo The Go gopher@Renee French. http://goo.gl/q6msPI CC BY 3.0
  18. 18. 䛹䛳䛛䞊䛾⤂௓䛷䛧䛯 䛤Ύ⫈ 䛒䜚䛜䛸䛖䛤䛦䛔䜎䛧䛯
  19. 19. 䜅䜝䛟䚷䛹䛳䛛䞊䛾౑䛔᪉ ⎔ቃ 䚷Ubuntu14.04 x64 䚷䈜VMWarePlayer 6䛷ືస
  20. 20. 䛹䛳䛛䞊䛾౑䛔᪉ Docker䜢䜲䞁䝇䝖䞊䝹 $ sudo apt-get update $ sudo apt-get install docker.io
  21. 21. 䛹䛳䛛䞊䛾౑䛔᪉ Docker䝁䝬䞁䝗䜢᭷ຠ໬ $ source /etc/bash_completion.d/docker.io
  22. 22. 䛹䛳䛛䞊䛾౑䛔᪉ Docker䝞䞊䝆䝵䞁☜ㄆ $ sudo docker --version
  23. 23. 䛹䛳䛛䞊䛾౑䛔᪉ Docker䜲䝯䞊䝆䛾᳨⣴䚷(౛䠖Ubuntu᳨⣴) $ sudo docker search ubuntu Docker䜲䝯䞊䝆䜢ྲྀᚓ䚷(౛䠖Ubuntuྲྀᚓ) $ sudo docker pull ubuntu
  24. 24. 䛹䛳䛛䞊䛾౑䛔᪉ ྲྀᚓ῭䜏Docker䜲䝯䞊䝆୍ぴ $ sudo docker images
  25. 25. 䛹䛳䛛䞊䛾౑䛔᪉ Docker䝁䞁䝔䝘సᡂ(㉳ື) $ sudo docker run -i -t ubuntu /bin/bash 䈜䛂ubuntu䛃䛿䜲䝯䞊䝆ྡ 䚷䛂/bin/bash䛃䛿ᐇ⾜䝁䝬䞁䝗
  26. 26. 䛹䛳䛛䞊䛾౑䛔᪉ Docker䝁䞁䝔䝘୍ぴ $ sudo docker ps -a 䈜㉳ື୰䛾䜒䛾䛾䜏䛺䜙-a䜸䝥䝅䝵䞁䛿୙せ
  27. 27. 䛹䛳䛛䞊䛾౑䛔᪉ Docker䝁䞁䝔䝘䛾෌㉳ື $ sudo docker start (ID) $ sudo docker attach --sig-proxy=false (ID) 䈜docker run䛿䝁䞁䝔䝘䜢᪂つసᡂ䛩䜛䛾䛷䚸෌㉳ື䛿docker start䜢౑䛖 䚷ID䛿䝁䞁䝔䝘䛾ID䛷䚸୍ព䛻䛺䜜䜀ୖ䠐᱆⛬ᗘ䛷OK
  28. 28. 䛹䛳䛛䞊䛾౑䛔᪉ Docker䝁䞁䝔䝘䛾๐㝖䚷䈜ID䛿䝁䞁䝔䝘䛾ID $ sudo docker rm (ID) Docker䜲䝯䞊䝆䛾๐㝖䚷䈜ID䛿䜲䝯䞊䝆䛾ID $ sudo docker rmi (ID)

×