{"id":1091,"date":"2016-03-31T11:20:04","date_gmt":"2016-03-31T09:20:04","guid":{"rendered":"http:\/\/www.ayhanarda.com\/blog\/?p=1091"},"modified":"2016-03-31T11:20:04","modified_gmt":"2016-03-31T09:20:04","slug":"centos-7-de-docker-ve-docker-compose-kurulumu-ile-kullanimi","status":"publish","type":"post","link":"https:\/\/www.ayhanarda.com\/blog\/2016\/03\/centos-7-de-docker-ve-docker-compose-kurulumu-ile-kullanimi\/","title":{"rendered":"Centos 7 &#8216;de Docker ve Docker Compose Kurulumu ile Kullan\u0131m\u0131"},"content":{"rendered":"<p>Docker Compose, multi-container uygulamalar\u0131n\u0131z\u0131 gereksinimleri ile birlikte tek bir dosyaya tan\u0131mlayarak akabinde tek bir komut ile re\u00e7etesini yazd\u0131\u011f\u0131n\u0131z container \u0131 aya\u011fa kald\u0131rman\u0131z\u0131 sa\u011flamaktad\u0131r.<\/p>\n<p>\u015eimdi elimizde s\u0131f\u0131r kurulu ve updateleri yap\u0131lm\u0131\u015f bir centos 7 var , bir public ip verdim ( burada bolca var \ud83d\ude42 ) , siz private ip de verebilirsiniz , sonu\u00e7 olarak ssh eri\u015fimim de var ve makina bir \u015fekilde internete \u00e7\u0131k\u0131yor, buraya kadar tamam ise konuya girebiliriz.<\/p>\n<p>Bu arada docker compose eski fig in yerini ald\u0131 , fig duyar iseniz art\u0131k o deprecated oldu ve resmi olarak docker compose diye an\u0131l\u0131yor.<\/p>\n<p>\u00d6ncelikle Docker imajlar\u0131 hakk\u0131nda bilgi verelim , Her bir docker container \u0131 , bir docker imaj\u0131n\u0131n yerel\u00a0bir kopyas\u0131d\u0131r. Docker imajlar\u0131n\u0131 bir linux i\u015fletim sistemi gibi d\u00fc\u015f\u00fcnebilirsiniz ancak \u015f\u00f6\u015fnde sadece minimal gereksinimler bulunmaktad\u0131r ve bu imajlar ana host un kernel ini kullan\u0131rlar fakat \u00e7al\u0131\u015fan bir container \u0131n i\u00e7ine girerseniz sadece o container \u0131n dosya sistemini g\u00f6r\u00fcrs\u00fcn\u00fcz.<\/p>\n<p>En \u00e7ok kullan\u0131lan imaj lar\u0131 docker hub da bulabilirsiniz , Bunlar docker team taraf\u0131ndan kontrol edilir ve baz\u0131 imajlar\u0131n alt\u0131nda official ibaresini g\u00f6r\u00fcr iseniz bu imajlara g\u00fcvenebilirsiniz \u00e7\u00fcnk\u00fc docker team bunlar\u0131 test etmi\u015ftir.<\/p>\n<p>\u015eimdi docker kurarak ba\u015flayal\u0131m , bu i\u015f i\u00e7in yine docker team \u0131n haz\u0131rlad\u0131\u011f\u0131 bir shell script i \u00e7a\u011f\u0131r\u0131p \u00e7al\u0131\u015ft\u0131raca\u011f\u0131z.<\/p>\n<p>Centos 7 de wget \u00f6ntan\u0131ml\u0131 gelmiyor , a\u015fa\u011f\u0131daki komut ile indirebilirsiniz.<\/p>\n<p><strong>yum install wget<\/strong><\/p>\n<p>\u015eimdi scriptimizi \u00e7ekiyor ve \u00e7al\u0131\u015ft\u0131r\u0131yoruz.<\/p>\n<p>[root@ayhanarda-containers\u00a0~]#<strong> wget -qO- https:\/\/get.docker.com\/ | sh<\/strong><\/p>\n<p>Yakla\u015f\u0131k 30 sn i\u00e7inde kurulum tamamland\u0131 , \u015fimdi kurulup kurulmad\u0131\u011f\u0131n\u0131 a\u015fa\u011f\u0131daki \u015fekilde do\u011frulayabiliriz.<\/p>\n<p>[root@ayhanarda-containers ~]#<strong> docker version<\/strong><br \/>\nClient:<br \/>\nVersion: 1.10.3<br \/>\nAPI version: 1.22<br \/>\nGo version: go1.5.3<br \/>\nGit commit: 20f81dd<br \/>\nBuilt: Thu Mar 10 15:39:25 2016<br \/>\nOS\/Arch: linux\/amd64<\/p>\n<p>E\u011fer docker \u0131 root olmayan bir kullan\u0131c\u0131 ile kullanacak iseniz a\u015fa\u011f\u0131daki komutla kendinizi docker grubuna dahil edebilirsiniz.<\/p>\n<p><strong>usermod -aG docker $(whoami)<\/strong><\/p>\n<p>E\u011fer root iseniz yukar\u0131daki komutu kullanman\u0131za gerek yok , \u015fimdi docker \u0131 ba\u015flatal\u0131m ve bundan sonraki rebootlar sonunda tekrar \u00e7al\u0131\u015facak hale getirelim , a\u015fa\u011f\u0131daki 2 komutu kullanabilirsiniz.<\/p>\n<p>[root@ayhanarda-containers ~]# <strong>systemctl enable docker.service<\/strong><br \/>\nCreated symlink from \/etc\/systemd\/system\/multi-user.target.wants\/docker.service to \/usr\/lib\/systemd\/system\/docker.service.<br \/>\n[root@ayhanarda-containers ~]# <strong>systemctl start docker.service<\/strong><\/p>\n<p>Art\u0131k docker \u00e7al\u0131\u015f\u0131r durumda. \u015eimdi docker compose kurulumuna ge\u00e7ebiliriz.<\/p>\n<p>\u00d6ncelikle\u00a0python-pip kuruyorum \u00e7\u00fcnk\u00fc docker compose u pip ile kuraca\u011f\u0131m.<\/p>\n<p>[root@ayhanarda-containers ~]# <strong>yum install epel-release<\/strong><\/p>\n<p>[root@ayhanarda-containers ~]# <strong>yum install -y python-pip<\/strong><\/p>\n<p>\u015eimdi docker compose u kuruyoruz.<\/p>\n<p>[root@ayhanarda-containers ~]# <strong>pip install docker-compose<\/strong><\/p>\n<p>Kurulum tamamland\u0131.\u015eimdi hemen docker compose ile bir container aya\u011fa kald\u0131ral\u0131m.<\/p>\n<p>\u015eimdi yaml dosyam\u0131z i\u00e7in bir klas\u00f6r a\u00e7\u0131p i\u00e7ine giriyorum.<\/p>\n<p>[root@ayhanarda-containers ~]# <strong>mkdir hello-world<\/strong><br \/>\n[root@ayhanarda-containers ~]# <strong>cd hello-world<\/strong><\/p>\n<p>docker-compose.yml isimli dosyam\u0131z\u0131 olu\u015fturup i\u00e7ine re\u00e7etemizi yazaca\u011f\u0131z. Ben favori edit\u00f6r olarak nano kullan\u0131yorum , Siz farkl\u0131 bir editor kullanabilirsiniz.<\/p>\n<p>[root@ayhanarda-containers hello-world]# nano docker-compose.yml<\/p>\n<p>i\u00e7ine a\u015fa\u011f\u0131daki sat\u0131rlar\u0131 yazabilir ve kaydedebilirsiniz.<\/p>\n<p>ayhanarda-test:<br \/>\nimage: hello-world<\/p>\n<p>Yani a\u015fa\u011f\u0131daki gibi g\u00f6z\u00fckmeli.<\/p>\n<p>[root@ayhanarda-containers hello-world]# <strong>cat docker-compose.yml<\/strong><br \/>\nayhanarda-test:<br \/>\nimage: hello-world<\/p>\n<p>\u015eimdi yapmam\u0131z gereken tek bir hareket kald\u0131 , bu prospekt\u00fcs\u00fcn yaz\u0131l\u0131 oldu\u011fu container\u0131 up etmek , hala hello-world klas\u00f6r\u00fcm\u00fcz\u00fcn i\u00e7inde iken a\u015fa\u011f\u0131daki komutu kullanabilirsiniz.<\/p>\n<p>[root@ayhanarda-containers hello-world]# <strong>docker-compose up<\/strong><br \/>\nPulling ayhanarda-test (hello-world:latest)&#8230;<br \/>\nlatest: Pulling from library\/hello-world<br \/>\n03f4658f8b78: Pull complete<br \/>\na3ed95caeb02: Pull complete<br \/>\nDigest: sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7<br \/>\nStatus: Downloaded newer image for hello-world:latest<br \/>\nCreating helloworld_ayhanarda-test_1<br \/>\nAttaching to helloworld_ayhanarda-test_1<br \/>\nayhanarda-test_1 |<br \/>\nayhanarda-test_1 | Hello from Docker.<br \/>\n&#8230;<br \/>\n..<\/p>\n<p>\u015eimdi belirtti\u011fimiz image \u0131 indirdik , hadi bunu do\u011frulayal\u0131m.<\/p>\n<p>[root@ayhanarda-containers hello-world]# <strong>docker images<\/strong><br \/>\nREPOSITORY TAG IMAGE ID CREATED SIZE<br \/>\n<em>hello-world<\/em> latest 690ed74de00f 5 months ago 960 B<\/p>\n<p>\u015eimdi ayn\u0131 y\u00f6ntemle bir de nginx kuruyorum , bunu yazmayaca\u011f\u0131m , \u015fimdi docker hub da offical nginx i bulup ad\u0131n\u0131 do\u011frulay\u0131p ayn\u0131 y\u00f6ntem ile olu\u015fturabilirsiniz. Docker ps ile \u00e7al\u0131\u015ft\u0131\u011f\u0131n\u0131 g\u00f6rebilirsiniz.<\/p>\n<p>[root@ayhanarda-containers ~]# <strong>docker ps<\/strong><br \/>\nCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES<br \/>\ne37b79df162b nginx &#8220;nginx -g &#8216;daemon off&#8221; About a minute ago Up About a minute 80\/tcp, 443\/tcp nginx_nginx_1<\/p>\n<p>Yukar\u0131da bir Container id g\u00f6receksiniz , her \u00e7al\u0131\u015fan container \u0131n bir id si vard\u0131r, yani e\u011fer biz bu container \u0131n dosya sistemine girmek ister isek a\u015fa\u011f\u0131daki gibi o makinan\u0131n i\u00e7ine eri\u015febiliriz , hatta nginx in conf dosyas\u0131nda de\u011fi\u015fiklik yapabiliriz , i\u015fimiz bitince exit yazarak \u00e7\u0131kabiliriz.<\/p>\n<p>[root@ayhanarda-containers ~]# <strong>docker exec -it e37b79df162b \/bin\/bash<\/strong><br \/>\nroot@e37b79df162b:\/# cd etc\/nginx\/conf.d\/<br \/>\nroot@e37b79df162b:\/etc\/nginx\/conf.d# ls<br \/>\ndefault.conf<\/p>\n<p>Farkl\u0131 docker-compose ve multi-container \u00f6rnekleri ile yak\u0131nda g\u00f6r\u00fc\u015fmek \u00fczere..<\/p>\n<p>Ayhan ARDA<\/p>\n<div style=\"padding-bottom:20px; padding-top:10px;\" class=\"hupso-share-buttons\"><!-- Hupso Share Buttons - https:\/\/www.hupso.com\/share\/ --><a class=\"hupso_toolbar\" href=\"https:\/\/www.hupso.com\/share\/\"><img decoding=\"async\" src=\"https:\/\/static.hupso.com\/share\/buttons\/lang\/tr\/share-medium.png\" style=\"border:0px; padding-top: 5px; float:left;\" alt=\"Share Button\"\/><\/a><script type=\"text\/javascript\">var hupso_services_t=new Array(\"Twitter\",\"Facebook\",\"Google Plus\",\"Pinterest\",\"Linkedin\");var hupso_background_t=\"#EAF4FF\";var hupso_border_t=\"#66CCFF\";var hupso_toolbar_size_t=\"medium\";var hupso_image_folder_url = \"\";var hupso_twitter_via=\"ayhanarda\";var hupso_url_t=\"\";var hupso_title_t=\"Centos%207%20%27de%20Docker%20ve%20Docker%20Compose%20Kurulumu%20ile%20Kullan%C4%B1m%C4%B1\";<\/script><script type=\"text\/javascript\" src=\"https:\/\/static.hupso.com\/share\/js\/share_toolbar.js\"><\/script><!-- Hupso Share Buttons --><\/div>","protected":false},"excerpt":{"rendered":"Docker Compose, multi-container uygulamalar\u0131n\u0131z\u0131 gereksinimleri ile birlikte tek bir dosyaya tan\u0131mlayarak akabinde tek bir komut ile re\u00e7etesini yazd\u0131\u011f\u0131n\u0131z container \u0131 aya\u011fa kald\u0131rman\u0131z\u0131 sa\u011flamaktad\u0131r. \u015eimdi elimizde s\u0131f\u0131r kurulu ve updateleri yap\u0131lm\u0131\u015f bir centos 7 var , bir public ip verdim ( burada bolca var \ud83d\ude42 ) , siz private ip de verebilirsiniz , sonu\u00e7 olarak ssh [&hellip;]","protected":false},"author":1,"featured_media":1092,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"categories":[282,732,66,902,67],"tags":[990,988,989,733,991,985,983,735,986,981,987,984,982],"class_list":["post-1091","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-docker","category-linux-2","category-sanallastirma","category-shell-script","tag-ayhan-arda-docker","tag-centos-docker","tag-centos7-docker","tag-docker","tag-docker-egitimi","tag-docker-hello-world","tag-docker-install","tag-docker-kurulumu","tag-docker-merhaba-dunya","tag-docker-compose","tag-docker-compose-commands","tag-docker-compose-install","tag-docker-compose-kurulumu"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ayhanarda.com\/blog\/wp-json\/wp\/v2\/posts\/1091","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ayhanarda.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ayhanarda.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ayhanarda.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ayhanarda.com\/blog\/wp-json\/wp\/v2\/comments?post=1091"}],"version-history":[{"count":1,"href":"https:\/\/www.ayhanarda.com\/blog\/wp-json\/wp\/v2\/posts\/1091\/revisions"}],"predecessor-version":[{"id":1093,"href":"https:\/\/www.ayhanarda.com\/blog\/wp-json\/wp\/v2\/posts\/1091\/revisions\/1093"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ayhanarda.com\/blog\/wp-json\/wp\/v2\/media\/1092"}],"wp:attachment":[{"href":"https:\/\/www.ayhanarda.com\/blog\/wp-json\/wp\/v2\/media?parent=1091"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ayhanarda.com\/blog\/wp-json\/wp\/v2\/categories?post=1091"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ayhanarda.com\/blog\/wp-json\/wp\/v2\/tags?post=1091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}