ãã®èšäºã¯ãDockerã«ã€ããŠæ¢ã«ç¥ã£ãŠãã人ãDockerã®ç®çãç¥ã£ãŠãã人ã察象ãšããŠããŸãã ãããã圌ã¯æ¬¡ã«äœããã¹ããããããŸããã ãã®èšäºã¯æ¬è³ªçã«å©èšã§ãããããã¹ããã©ã¯ãã£ã¹ãã®ã¿ã€ãã«ã䟵害ãããã®ã§ã¯ãããŸããã
ãããã£ãŠãããããdockerãã¥ãŒããªã¢ã«ãèªãã ãããããŸããããdockerã¯ã·ã³ãã«ã§äŸ¿å©ãªããã«èŠããŸããããããžã§ã¯ãã§ã©ã®ããã«åœ¹ç«ã€ãã¯ãŸã ããããŸããã
éåžžãå±éã«ã¯3ã€ã®åé¡ããããŸãã
- ãµãŒããŒã«ã³ãŒããé ä¿¡ããã«ã¯ã©ãããã°ããã§ããïŒ
- ãµãŒããŒã§ã³ãŒããå®è¡ããã«ã¯ã©ãããã°ããã§ããïŒ
- ã³ãŒããéå§ããŠå®è¡ããç°å¢ãšåãç°å¢ã確ä¿ããã«ã¯ã©ãããã°ããã§ããïŒ
Dockerãç«ã®äžã§ãããã©ã®ããã«æ¯æŽãããã ããã§ã¯ãDockerã§ã¯ãªããDockerãªãã§ã®ç掻ããå§ããŸãããã
ãµãŒããŒã«ã³ãŒããé ä¿¡ããã«ã¯ã©ãããã°ããã§ããïŒ
æåã«æãæµ®ãã¶ã®ã¯ããã¹ãŠãããã±ãŒãžã«è©°ããããšã§ãã RPMãŸãã¯DEBã¯é¢ä¿ãããŸããã
ããã±ãŒãž
ã·ã¹ãã ã«ã¯ããã¡ã€ã«ã管çã§ããããããããŒãžã£ãŒãæ¢ã«ãããŸããéåžžã¯ã次ã®ãã®ãå¿ èŠã§ãã
- äžéšã®ã¹ãã¬ãŒãžãããããžã§ã¯ããã¡ã€ã«ããµãŒããŒã«é ä¿¡ãã
- äŸåé¢ä¿ãæºããïŒã©ã€ãã©ãªãã€ã³ã¿ãŒããªã¿ãŒãªã©ïŒ
- 以åã®ããŒãžã§ã³ã®ãã¡ã€ã«ãåé€ããçŸåšã®ãã¡ã€ã«ãé ä¿¡ããŸãã
å®éã«ã¯ãä»ã®ãšããåäœããŸã...ç¶æ³ãæ³åããŠãã ããã ããªãã¯ç¶ç¶çã«DevOpsã§ãã ã€ãŸã 管çè ãé¢äžããæ¥åžžçãªæŽ»åã®èªååã«1æ¥è²»ãããŸãã ãã£ã¹ããªãã¥ãŒã·ã§ã³ããåç©åã飌è²ããŠããªãå°ããªè»äž¡çŸ€ããããŸãã ããšãã°ãCentosã倧奜ãã§ãã 圌女ã¯ã©ãã«ã§ãããŸãã ããããããã§åé¡ãçããŸãããããžã§ã¯ãã®1ã€ãlibxxã«çœ®ãæããã«ã¯ãlibyyïŒCentosã®äžã«ãããŸãïŒã眮ãæããå¿ èŠããããŸãã 亀æããçç±-ããªãã¯ç¥ããŸããã ã»ãšãã©ã®å Žåãéçºè ã¯libxxã«å¯ŸããŠã®ã¿ããã€ãã®ããã«krivorukyããäœæããlibyyã§ã¯æ©èœããŸããã ããŠãvimãæã«å ¥ããŠãlibxxã®rpmspecãèšè¿°ããŸããããã¯ãã¢ã»ã³ããªã«å¿ èŠãªã©ã€ãã©ãªã®æ°ããããŒãžã§ã³ã«ã€ããŠäžŠè¡ããŠèšè¿°ããŸãã çŽ2ã3æ¥éã®éåã§ãçµæã¯æ¬¡ã®ãšããã§ãã
- libxxãå®è¡ããããã¹ãŠãæ£åžžã§ãã¿ã¹ã¯ãå®äºããŸãã
- libxxããã«ããããªãã£ãã®ã¯ãããšãã°ãã·ã¹ãã ã«libyyãã€ã³ã¹ããŒã«ãããŠãããããåé€ããå¿ èŠãããããã§ããããµãŒããŒäžã®ä»ã®äœããããã«äŸåããŠããããã§ã
- libxxã¯æ§ç¯ãããŠããŸãããä»ã®ã©ã€ãã©ãªãšç«¶åããã©ã€ãã©ãªãååã«ãããŸãã
ã¿ã¹ã¯ã«å¯ŸåŠãã確çã®åèšã¯çŽ30ïŒ ã§ãïŒãã ããå®éã«ã¯ãªãã·ã§ã³2ãŸãã¯3ã¯åžžã«ããããã¢ãŠãããŸãïŒã ãããŠã2çªç®ã®ç¶æ³ããŸã äœããã®æ¹æ³ã§åŠçã§ããå ŽåïŒä»®æ³ãã·ã³ãååšãããlxcïŒã3çªç®ã®ç¶æ³ã¯ããªãã®åç©åã«å¥ã®ç£ãè¿œå ãããããã³ãã«ä»ãã§/ usr / localã«null / slakvariã®æšæ¶ãåéããŸã
äžè¬çã«ããã®ç¶æ³ã¯äŸåæ§å°çãšåŒã°ããŸãã ããã«ã¯ãåçŽãªchrootããNixOsã®ãããªè€éãªãããžã§ã¯ããŸã§ã æ°å€ãã®ãœãªã¥ãŒã·ã§ã³ããããŸãã
ãªãç§ã¯ãããããŠããŸããã ããããã ããã±ãŒãžå ã®ãã¹ãŠãåéããåãã·ã¹ãã äžã§ããããé§åãå§ãããšããã«ãééããªãäŸåé¢ä¿ã®å°çã®ç¶æ³ã«ãªããŸãã ããŸããŸãªæ¹æ³ã§è§£æ±ºã§ããŸãã åãããžã§ã¯ãã«æ°ãããªããžããªãšæ°ããä»®æ³ãã·ã³/ããŒããŠã§ã¢ãè¿œå ããããå¶éãå°å ¥ããŸãã å¶éãšã¯ã次ã®ãããªäŒæ¥ããªã·ãŒã®ç¹å®ã®ã»ãããæå³ããŸãããããã«ã¯libyy-vN.NãããããŸããã æ°ã«å ¥ããªã人ã¯èª°ã§ã声æã§äººäºéšã«é£çµ¡ããŠãã ãããã ç§ã¯NNã«ã€ããŠã ãèšã£ãã®ã§ã¯ãªããããã€ãã®ã©ã€ãã©ãªã¯2ã€ã®ããŒãžã§ã³ã§åããµãŒããŒäžã«ååšã§ããŸããã å¶éã¯æçµçã«äœãäžããŸããã ããžãã¹ããããŠåžžèã¯ããã«ããããã¹ãŠãç Žå£ããŸãã
ããéèŠãªããšã¯èªåã§èããŠãã ããïŒãµãŒãããŒãã£ã®ã³ã³ããŒãã³ãã®æŽæ°ã«äŸåãã補åã®æ©èœãäœæããããç°å¢ã®ç°è³ªæ§ã楜ããããã®æéãäžããããšã§ãã
GITãä»ããŠå±éãã
éèš³èšèªã«é©ããŠããŸãã ã³ã³ãã€ã«ããå¿ èŠããããã®ã«ã¯é©ããŠããŸããã ãŸããdependency-hellãåé€ããªãã§ãã ããã
ãµãŒããŒã§ã³ãŒããå®è¡ããã«ã¯ã©ãããã°ããã§ããïŒ
ãã®è³ªåã®ããã«ãdaemontoolsãrunitãsupervisorã®ãããªå€ãã®ãã®ãçºæãããŸããã ãã®è³ªåã«ã¯å°ãªããšã1ã€ã®æ£è§£ããããšèããŠããŸãã
ã³ãŒããéå§ããŠå®è¡ããç°å¢ãšåãç°å¢ã確ä¿ããã«ã¯ã©ãããã°ããã§ããïŒ
ãããµããç¶æ³ãæ³åããŠãã ãããããªãã¯ãŸã åãDevOpsã§ãããã¿ã¹ã¯ã¯ããªãã«ãã£ãŠæ¥ãŸãããEniacããããžã§ã¯ãïŒãããžã§ã¯ãã®ååãžã§ãã¬ãŒã¿ãŒããååŸãããŸãïŒãNãµãŒããŒã«ãããã€ããå¿ èŠããããŸãã
EniacãGITãããã©ãã°ãããšãæ¢ç¥ã®æè¡ïŒDjango / RoR / Go /
åé¡ãç解ããã å ã«é²ããšã1å°ã®ãµãŒããŒã§Eniacãå®è¡ã§ããŸãããããã§ãN-1ã§ã¯åäœããŸããã
Dockerã¯ã©ã®ããã«åœ¹ç«ã¡ãŸããïŒ
ãŸããæåã«ããããžã§ã¯ããããŒããŠã§ã¢ã«é ä¿¡ããæ段ãšããŠDockerã䜿çšããæ¹æ³ãç解ããŸãããã
ãã©ã€ããŒãDockerã¬ãžã¹ããª
Dockerã¬ãžã¹ããªãšã¯äœã§ããïŒ ããã¯ãdebããã±ãŒãžãšãããã®ã¡ã¿ããŒã¿ãã¡ã€ã«ãé åžããWEBãµãŒããŒã®ããã«ãããŒã¿ãä¿åãããã®ã§ãã Amazonã®ä»®æ³ãã·ã³ã«Docker Hubãã€ã³ã¹ããŒã«ããŠAmazon S3ã«ããŒã¿ãä¿åããããã€ã³ãã©ã¹ãã©ã¯ãã£ã«ã€ã³ã¹ããŒã«ããŠCephãŸãã¯FSã«ããŒã¿ãä¿åã§ããŸãã
Dockerã¬ãžã¹ããªèªäœã¯ãdockerã«ãã£ãŠèµ·åããããšãã§ããŸãã ããã¯åãªãPythonã¢ããªã±ãŒã·ã§ã³ã§ãïŒæããã«ãå€ãã®ã¬ãžã¹ããªããµããŒãããŠãããªããžããªçšã®ã©ã€ãã©ãªãäœæããããšã¯ã§ããŸããã§ããïŒã
ãããŠããããžã§ã¯ãããã®ãªããžããªã«ã©ã®ããã«åã蟌ãŸããããåŸã§åæããŸãã
ãµãŒããŒã§ã³ãŒããå®è¡ããã«ã¯ã©ãããã°ããã§ããïŒ
ããã§ã¯ããããžã§ã¯ãã®é ä¿¡æ¹æ³ãéåžžã®ããã±ãŒãžãããŒãžã£ãŒãšæ¯èŒããŠã¿ãŸãããã ããšãã°ãaptïŒ
apt-get update && apt-get install -y myuperproject
ãã®ã³ãã³ãã¯èªååã«é©ããŠããŸãã 圌女èªèº«ããã¹ãŠãéãã«è¡ããŸããã¢ããªã±ãŒã·ã§ã³ãåèµ·åããå¿ èŠããããŸãã
Dockerã®äŸïŒ
docker run -d 192.168.1.1:80/reponame/mysuperproject:1.0.5rc1 superproject-run.sh
ãããŠããã ãã§ãã Dockerã¯192.168.1.1ã«ããdockerã¬ãžã¹ããªããããŠã³ããŒãããããŒã80ïŒããã«ã¯nginxããããŸãïŒã§ãªãã¹ã³ããŸããããã¯ãèµ·åã«å¿ èŠãªãã¹ãŠã®ãã®ã§ãã€ã¡ãŒãžå ã§superproject-run.shãå®è¡ããŸãã
å®è¡ããã€ã¡ãŒãžã«2ã€ã®ããã°ã©ã ããããããšãã°æ¬¡ã®ãªãªãŒã¹ã§ã¯ããã®ãã¡ã®1ã€ãã¯ã©ãã·ã¥ããå Žåãä»ã®ããã°ã©ã ã¯ããŒã«ã¢ãŠãããå¿ èŠã®ããæ©èœãå ¥åããå Žåã«ã©ããªããŸããã åé¡ãããŸããïŒ
docker run -d 192.168.1.1:80/reponame/mysuperproject:1.0.10 superproject-run.sh docker run -d 192.168.1.1:80/reponame/mysuperproject:1.0.5rc1 broken-program.sh
ãããŠä»ãç§ãã¡ã¯ãã§ã«2ã€ã®ç°ãªãã³ã³ãããæã£ãŠããŸãããããŠãããã®äžã«ã·ã¹ãã ãã¡ã€ã«ã©ã€ãã©ãªãªã©ã®å®å šã«ç°ãªãããŒãžã§ã³ããããããããŸããã
ã³ãŒããéå§ããŠå®è¡ããç°å¢ãšåãç°å¢ã確ä¿ããã«ã¯ã©ãããã°ããã§ããïŒ
æšæºã®ä»®æ³ãã·ã³ãŸãã¯äžè¬çãªå®éã®ã·ã¹ãã ã®å Žåããã¹ãŠãèªåã§è¡ãå¿ èŠããããŸãã ãŸããã·ã§ã/ Ansible / Puppetãªã©ãå匷ããŠãã ããã ãã以å€ã®å Žåãxxx-utilsããã¹ãŠã®NãµãŒããŒã§åãããŒãžã§ã³ã§ãããšããä¿èšŒã¯ãããŸããã
Dockerã®å Žåãäœãããå¿ èŠã¯ãªããåãç»åããã³ã³ãããå±éããã ãã§ãã
ã³ã³ããçµç«
ã³ãŒããdockerã¬ãžã¹ããªã«ååŸããã«ã¯ïŒãŠãŒã¶ãŒãŸãã¯ã°ããŒãã«ã¯é¢ä¿ãããŸããïŒãããã«ããã·ã¥ããå¿ èŠããããŸãã
éçºè ã«ã³ã³ãããèªåã§äœæãããããšãã§ããŸãïŒ
- éçºè ãDockerfileãäœæ
- docker tag $ imageId 192.168.1.1:80/reponame/mysuperproject:1.0.5rc1
- ãããŠãããã«ãŒããã·ã¥192.168.1.1:80/reponame/mysuperproject:1.0.5rc1ãããã·ã¥ããŸã
ãŸãã¯èªåçã«åéããŸãã ã³ã³ãããåéãããã®ãèŠã€ãããªãã£ãã®ã§ã ããã«ã¯ã©ã³ããŒãšåŒã°ããçµã¿ç«ãŠãããèªè»¢è»ããããŸã
äžçªäžã®è¡ã¯æ¬¡ã®ãšããã§ãã
- ãµãŒããŒã«3ã€ã®ã³ã³ããŒãã³ãlumperãšRabbitMQãã€ã³ã¹ããŒã«ããŸã
- githubããã¯ã®ããŒãããªãã¹ã³ããŸãã
- ã©ã³ããŒã€ã³ã¹ããŒã«ã®github web-hookã§æ§æããŸã
- éçºè ã¯git tag v0.0.1 && git push --tagsãäœæããŸã
- ãã«ãçµæãèšèŒãããã¡ãŒã«ãåãåã
Dockerfile
å®éãè€éãªããšã¯äœããããŸããã ããšãã°ãDockerfileã䜿çšããŠã©ã³ããŒãæ§ç¯ããŸãã
FROM ubuntu:14.04 MAINTAINER Dmitry Orlov <me@mosquito.su> RUN apt-get update && \ apt-get install -y python-pip python-dev git && \ apt-get clean ADD . /tmp/build/ RUN pip install --upgrade --pre /tmp/build && rm -fr /tmp/build ENTRYPOINT ["/usr/local/bin/lumper"]
ããã§ãFROMã¯ãç»åãã©ã®ç»åã«åºã¥ããŠãããã«ã€ããŠèª¬æããŸãã 次ã«ãRUNã¯ç°å¢ãæºåããã³ãã³ããå®è¡ããŸãã ADDã¯ã³ãŒãã/ tmp / buildã«é 眮ããENTRYPOINTã¯ã³ã³ãããžã®ãšã³ããªãã€ã³ãã瀺ããŸãã ãããã£ãŠãèµ·åæã«docker run -it --rm mosquito / lumper --helpãšèšè¿°ãããšãåºå--help entrypointã衚瀺ãããŸã ã
ãããã«
ãµãŒããŒã§ã³ã³ãããå®è¡ããã«ã¯ãããã€ãã®æ¹æ³ããããŸããinitã¹ã¯ãªãããèšè¿°ããããã³ã³ãããããœãªã¥ãŒã·ã§ã³å šäœãå±éã§ããFigãèŠãŠãã ããã
ãŸããããŒããã©ã¯ãŒãã£ã³ã°ãšã³ã³ããã®IPã«ãŒãã£ã³ã°ã®ãããã¯ãæå³çã«ç¡èŠããŸããã
ãŸãããã®æè¡ã¯è¥ââããããDockerã«ã¯å·šå€§ãªã³ãã¥ããã£ããããŸãã ãããŠçŽ æŽãããããã¥ã¡ã³ã ã ãæž èŽããããšãããããŸããã