{"id":22013,"date":"2020-07-10T12:45:13","date_gmt":"2020-07-10T12:45:13","guid":{"rendered":"http:\/\/dev.profelis.net\/?p=16731"},"modified":"2023-02-01T10:57:59","modified_gmt":"2023-02-01T07:57:59","slug":"postgres-on-docker-volumes","status":"publish","type":"post","link":"https:\/\/profelis.com.tr\/en\/2020\/07\/10\/postgres-on-docker-volumes\/","title":{"rendered":"Postgres on Docker &#8212; volumes"},"content":{"rendered":"<p><span style=\"font-weight: 400; color: #000000;\">Yaz\u0131 dizimize Docker \u00fczerinde PostgreSQL ve PgAdmin kurulumuyla ba\u015flam\u0131\u015ft\u0131k. Devam\u0131nda ise Docker\u2019da \u00f6nemli bir di\u011fer konu olan volume y\u00f6netimini inceleyece\u011fiz. Bunun i\u00e7in i\u015fe PostgreSQL 11 imaj\u0131n\u0131 \u00e7al\u0131\u015ft\u0131rarak ba\u015flayaca\u011f\u0131z. Ba\u015fka bir s\u00fcr\u00fcmle ba\u015flamay\u0131n \u00e7\u00fcnk\u00fc yaz\u0131n\u0131n devam\u0131nda verilerimizi bozmadan PostgreSQL 11.7\u2019ye g\u00fcncelleyece\u011fiz. Dolay\u0131s\u0131yla konteynerin kulland\u0131\u011f\u0131 veri dizinimiz etkilenmeden PostgreSQL\u2019in iki min\u00f6r s\u00fcr\u00fcm\u00fc taraf\u0131ndan kullan\u0131labilecek. Burada veri dizinini, takip edecek oldu\u011fumuz ve (bu iki PostgreSQL s\u00fcr\u00fcm\u00fcn\u00fcn) ortak dosyalar\u0131m\u0131z\u0131\/verilerimizi tuttu\u011fumuz klas\u00f6r olarak da d\u00fc\u015f\u00fcnebiliriz. A\u015fa\u011f\u0131daki komutta verilen -v etiketi volume ifadesini g\u00f6steriyor ve -e ile \u00e7evre de\u011fi\u015fkeni olarak superuser parolas\u0131n\u0131 tan\u0131ml\u0131yoruz.\u00a0<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">[profelis@profelis ~]$ docker run &#8211;name pg11 -d -e POSTGRES_PASSWORD=pass -v pg11data:\/var\/lib\/postgresql\/data postgres:11<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">Unable to find image <\/span><span style=\"font-weight: 400; color: #339966;\">&#8216;postgres:11&#8217;<\/span><span style=\"font-weight: 400;\"> locally<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">11: Pulling from library\/postgres<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">5e35bd43cf78: Pull complete <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">0df82dab3c88: Pull complete <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">0670a6d74375: Pull complete <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">bd2be22379ef: Pull complete <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">9eb829e5b266: Pull complete <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">95d7f9aaa5bd: Pull complete <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">de97a90167ed: Pull complete <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">4b50288dfea5: Pull complete <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">b71c4d54a488: Pull complete <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">e1828d0d4b60: Pull complete <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">dce8713bb72b: Pull complete <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">37db80a505c4: Pull complete <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">936725e631d9: Pull complete <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">86ab6b577e4f: Pull complete <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">Digest: sha256:32f2b2b831bcc5318183eb09915c97552f7c2a9657b225f9ea0d23ed727271bb<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">Status: Downloaded newer image <\/span><span style=\"font-weight: 400;\">for<\/span><span style=\"font-weight: 400;\"> postgres:11<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">2b891069b8bb9bfcb24952f4759ad66f9ad37134e35c6b0c41dc85e4242cd779<\/span><\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\">[profelis@profelis ~]$ docker container ls -a<\/span><\/p>\n<p style=\"font-size: 13px; padding-left: 40px;\"><span style=\"color: #000000;\">CONTAINER ID\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0IMAGE\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0COMMAND\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 CREATED\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0STATUS\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0PORTS\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0NAMES<\/span><br \/>\n<span style=\"color: #000000;\">2b891069b8bb\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 postgres:11\u00a0 \u00a0 \u00a0 \u00a0 &#8220;docker-entrypoint.s&#8230;&#8221;\u00a0 \u00a0 6 seconds ago\u00a0 \u00a0 \u00a0 \u00a0Up 4 seconds\u00a0 \u00a0 \u00a0 5432\/tcp\u00a0 \u00a0 \u00a0 \u00a0 pg11<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #000000;\">\u0130lk yaz\u0131da Docker\u2019da \u00e7al\u0131\u015fan konteynerlerin ya\u015fam d\u00f6ng\u00fcs\u00fcn\u00fc kontrol etmi\u015ftik ancak sistem kaynaklar\u0131n\u0131 nas\u0131l kulland\u0131\u011f\u0131n\u0131 ya da a\u011fda nas\u0131l bir davran\u0131\u015f g\u00f6sterdi\u011fini sonraki yaz\u0131lara b\u0131rakm\u0131\u015ft\u0131k. Asl\u0131nda Docker, kendi i\u00e7inde \u00e7al\u0131\u015fan t\u00fcm konteynerlerin hem s\u00fcre\u00e7lerini hem de disk kullan\u0131m alanlar\u0131n\u0131 birbirlerinden yal\u0131t\u0131r. Her konteyner, b\u00fcnyesinde ayr\u0131 i\u015fletim sistemi s\u00fcre\u00e7leri i\u015fletilirken ayr\u0131 disk alanlar\u0131nda \u00e7al\u0131\u015ft\u0131r\u0131l\u0131r.<\/span><\/p>\n<p><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Peki bir Docker konteyneri verilerini nereye yazar ya da yazar m\u0131? Bunu kim, nerede tan\u0131mlar? Bu sorular\u0131n cevaplar\u0131n\u0131 bulmak i\u00e7in \u00f6ncelikle Docker\u2019da volume kavram\u0131n\u0131 anlamak laz\u0131m. Evet, Docker konteynerleri de \u00fczerinde \u00e7al\u0131\u015ft\u0131\u011f\u0131 i\u015fletim sisteminde <\/span><b>\u201c\u00f6n tan\u0131ml\u0131\u201d<\/b><span style=\"font-weight: 400;\"> bir disk alan\u0131n\u0131 kullan\u0131yor ve biz bu disk alan\u0131n\u0131 kontrol edebiliyor ya da tan\u0131mlad\u0131\u011f\u0131m\u0131z ba\u015fka bir disk alan\u0131n\u0131 kullanabiliyoruz.\u00a0<\/span><\/span><\/p>\n<p><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">\u00d6ncelikle Docker konteynerleri <\/span><b>\u00f6l\u00fcml\u00fcd\u00fcr<\/b><span style=\"font-weight: 400;\">! Yani docker konteynerleri kapat\u0131ld\u0131\u011f\u0131nda i\u00e7lerinde olu\u015fturulan veriler de silinir. Docker, bir imajdan yeni bir konteyner \u00fcretti\u011finde, kullan\u0131c\u0131n\u0131n yapt\u0131\u011f\u0131 de\u011fi\u015fiklikler art\u0131k yoktur. Her Docker imaj\u0131nda \u00f6n tan\u0131ml\u0131 baz\u0131 ayarlar vard\u0131r ve bunlar\u0131n yer ald\u0131\u011f\u0131 dosya <\/span><b>Dockerfile<\/b><span style=\"font-weight: 400;\"> olarak ge\u00e7er. Diskte kullan\u0131lacak alan\u0131 temsilen Dockerfile\u2019da yer alan <\/span><b>volume <\/b><span style=\"font-weight: 400;\">tan\u0131m\u0131 da bu ayarlardan birisi olup imajdan \u00fcretilen konteynerde a\u00e7\u0131k\u00e7a tan\u0131mlanmas\u0131 halinde diskte verilerin <\/span><b>kal\u0131c\u0131<\/b><span style=\"font-weight: 400;\"> olarak saklanabilece\u011fi bir alan\u0131n \u00f6n tan\u0131m\u0131n\u0131 i\u00e7erir. Konteyner durdurulsa ve silinse dahi tan\u0131mlanm\u0131\u015f volume sayesinde konteynerde olu\u015fturulmu\u015f veriler Docker dosya sisteminde var olmaya devam edebilirler.<\/span> <span style=\"font-weight: 400;\">\u00d6zetle \u201c\u00f6l\u00fcml\u00fc\u201d Docker konteynerleri durdurulduklar\u0131nda verileri de beraberlerinde yok ederken, kullan\u0131c\u0131n\u0131n iste\u011fi do\u011frultusunda diskte saklama se\u00e7ene\u011fini de sunarlar. Bu t\u00fcr durumlarda konteynerde kalmas\u0131n\u0131 istedi\u011fimiz veriler i\u00e7in volume tan\u0131mlamas\u0131 yap\u0131lmal\u0131d\u0131r.\u00a0<\/span><\/span><\/p>\n<p><span style=\"font-weight: 400; color: #000000;\">Volume ismine ve konumuna karar verebilece\u011fimiz gibi bu atama i\u015flerini Docker\u2019a da b\u0131rakabiliriz. Ancak Docker otomatik isimlendirdi\u011fi volume\u2019lere genellikle \u201cinsani\u201d isimler de vermez. Bu s\u00fcreci ve sonras\u0131n\u0131 kolayca y\u00f6netmek istiyorsak konteynerin kullanaca\u011f\u0131 disk alan\u0131n\u0131 kendimiz tan\u0131mlar, b\u00f6ylece hem kullan\u0131lacak disk alan\u0131n\u0131 hem de volume i\u00e7in Docker\u2019\u0131n kullanaca\u011f\u0131 ismi belirleyebiliriz. Docker, disk alan\u0131 tan\u0131m\u0131 i\u00e7in Data Volume ve Bind Mount olmak \u00fczere iki farkl\u0131 kullan\u0131ma izin verir. Bu yaz\u0131da biz sadece Data Volume \u00fczerinden \u00f6rnek verece\u011fiz.\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">PostgreSQL 11 s\u00fcr\u00fcm\u00fcm\u00fcze ait imaj dosyas\u0131 pull ile Docker Registry\u2019den \u00e7ekildi ve \u00e7al\u0131\u015ft\u0131r\u0131ld\u0131. E\u011fer \u00e7al\u0131\u015fan konteyner imaj\u0131n\u0131<\/span><i><span style=\"font-weight: 400;\"> docker container inspect<\/span><\/i><span style=\"font-weight: 400;\">\u2019le sorgularsak konteynerin kulland\u0131\u011f\u0131 disk alan\u0131n\u0131 <\/span><b>Volumes <\/b><span style=\"font-weight: 400;\">ba\u015fl\u0131\u011f\u0131nda g\u00f6rece\u011fiz. Burada ayr\u0131ca <\/span><b>Mounts<\/b><span style=\"font-weight: 400;\"> k\u0131sm\u0131nda bulunan source (kaynak) ve destination (hedef) etiketleri de i\u015fletim sistemindeki hangi dizinin konteynerdeki hangi dizine y\u00f6nlendirildi\u011fini (ba\u011flant\u0131lar\u0131n\u0131n e\u015flendi\u011fini) g\u00f6rmek a\u00e7\u0131s\u0131ndan \u00f6nemli.\u00a0<\/span><\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">[profelis@profelis ~]$ docker container inspect pg11<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">&#8230;<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400; color: #339966;\">&#8220;Volumes&#8221;<\/span><span style=\"font-weight: 400;\">: {<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400; color: #339966;\">&#8220;\/var\/lib\/postgresql\/data&#8221;<\/span><span style=\"font-weight: 400;\">: {}<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 },<\/span><\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">&#8230;<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400; color: #339966;\">&#8220;Mounts&#8221;<\/span><span style=\"font-weight: 400;\">: [<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 {<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"color: #339966;\"><span style=\"font-weight: 400;\">&#8220;Type&#8221;<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">&#8220;volume&#8221;<\/span><span style=\"font-weight: 400; color: #000000;\">,<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">&#8220;Name&#8221;<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">&#8220;pg11data&#8221;<\/span><span style=\"font-weight: 400; color: #000000;\">,<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">&#8220;Source&#8221;<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">&#8220;\/var\/lib\/docker\/volumes\/pg11data\/_data&#8221;<\/span><span style=\"font-weight: 400; color: #000000;\">,<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">&#8220;Destination&#8221;<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">&#8220;\/var\/lib\/postgresql\/data&#8221;<\/span><span style=\"font-weight: 400; color: #000000;\">,<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">&#8220;Driver&#8221;<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">&#8220;local&#8221;<\/span><span style=\"font-weight: 400; color: #000000;\">,<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">&#8220;Mode&#8221;<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">&#8220;z&#8221;<\/span><span style=\"font-weight: 400; color: #000000;\">,<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">&#8220;RW&#8221;<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400; color: #3366ff;\">true<\/span><span style=\"font-weight: 400; color: #000000;\">,<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">&#8220;Propagation&#8221;<\/span><span style=\"font-weight: 400; color: #000000;\">: <\/span><span style=\"font-weight: 400;\">&#8220;&#8221;<\/span><\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 ],<\/span><\/span><\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"color: #000000;\">E\u011fer bir konteyner -v etiketi kullan\u0131lmadan \u00e7al\u0131\u015ft\u0131r\u0131l\u0131rsa Docker bu konteyneri, \/var\/lib\/docker\/volumes\/ alt\u0131nda hash isimli bir veri dizini olu\u015fturarak \u00e7al\u0131\u015ft\u0131racakt\u0131r. \u00d6rne\u011fin deneme ama\u00e7l\u0131 ba\u015fka PostgreSQL sunucusu olu\u015ftural\u0131m ve bir volume tan\u0131m\u0131 yapmayal\u0131m. Bu durumda yukar\u0131da bahsetti\u011fimiz gibi volume izlemelerini yapmam\u0131z\u0131 zorla\u015ft\u0131racak bi\u00e7imde Docker\u2019\u0131n \u201cinsani\u201d olmayan isimlendirmesiyle kar\u015f\u0131la\u015f\u0131r\u0131z.<\/span> <\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\">[omen@omen docker]$ docker run -d -e POSTGRES_PASSWORD=pass &#8211;name pg_test postgres:11<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\">2aee185beb35ecd78406bf8578301ffef11d9fdea69854bc51c16c03b8e521d5<\/span><br \/>\n<span style=\"color: #000000;\">[omen@omen docker]$ docker container\u00a0 ls<\/span><\/p>\n<p style=\"font-size: 13px; padding-left: 40px;\"><span style=\"color: #000000;\">CONTAINER ID\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0IMAGE\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0COMMAND\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 CREATED\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0STATUS\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0PORTS\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0NAMES<\/span><br \/>\n<span style=\"color: #000000;\">2b891069b8bb\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 postgres:11\u00a0 \u00a0 \u00a0 \u00a0<span style=\"color: #339966;\"> &#8220;docker-entrypoint.s&#8230;&#8221;<\/span>\u00a0 \u00a0 5 seconds ago\u00a0 \u00a0 \u00a0 \u00a0Up 4 seconds\u00a0 \u00a0 \u00a0 5432\/tcp\u00a0 \u00a0 \u00a0 \u00a0 pgtest<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">[omen@omen docker]$ docker volume ls<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">DRIVER\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 VOLUME NAME<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">local<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><b>f12cc8cf7eee61af18715ba70e16c9ea8fd167a175c3fbfbc32b9dd4f9ad8a2a<\/b><\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">[omen@omen docker]$ docker volume\u00a0 inspect <\/span><b>f12cc8cf7eee61af18715ba70e16c9ea8fd167a175c3fbfbc32b9dd4f9ad8a2a<\/b><span style=\"font-weight: 400;\">\u00a0<\/span><\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">[<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 {<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"color: #339966;\"><span style=\"font-weight: 400;\">&#8220;CreatedAt&#8221;<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\">&#8220;2020-04-21T07:10:16+03:00&#8221;<\/span><span style=\"font-weight: 400;\">,<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">&#8220;Driver&#8221;<\/span><\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400; color: #339966;\">&#8220;local&#8221;<\/span><span style=\"font-weight: 400;\">,<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400; color: #339966;\">&#8220;Labels&#8221;<\/span><span style=\"font-weight: 400;\">: null,<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400; color: #339966;\">&#8220;Mountpoint&#8221;<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400; color: #339966;\">&#8220;\/var\/lib\/docker\/volumes\/f12cc8cf7eee61af18715ba70e16c9ea8fd167a175c3fbfbc3<br \/>\n2b9dd4f9ad8a2a\/_data&#8221;<\/span><span style=\"font-weight: 400;\">,<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400; color: #339966;\">&#8220;Name&#8221;<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400; color: #339966;\">&#8220;f12cc8cf7eee61af18715ba70e16c9ea8fd167a175c3fbfbc32b9dd4f9ad8a2a&#8221;<\/span><span style=\"font-weight: 400;\">,<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400; color: #339966;\">&#8220;Options&#8221;<\/span><span style=\"font-weight: 400;\">: null,<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400; color: #339966;\">&#8220;Scope&#8221;<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400; color: #339966;\">&#8220;local&#8221;<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 }<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">]<\/span><\/span><span style=\"font-weight: 400;\"><span style=\"color: #000000;\">Bu volume\u2019de ne oldu\u011funa bakmak i\u00e7in yetkili kullan\u0131c\u0131ya ge\u00e7iyoruz ve Docker\u2019\u0131n saklad\u0131\u011f\u0131 volume\u2019\u00fcn i\u00e7ini inceledi\u011fimizde PostgreSQL veri dizinimizle kar\u015f\u0131la\u015f\u0131yoruz.<\/span> <\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">[omen@omen docker]$ sudo su &#8211;<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">[omen ~]<\/span><\/span><span style=\"font-weight: 400; color: #339966;\">#\u00a0 cd \/var\/lib\/docker\/volumes\/f12cc8cf7eee61af18715ba70e16c9ea8fd167a175c3fbfbc32<br \/>\nb9dd4f9ad8a2a\/_data\/<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400; color: #000000;\">[omen _data]<\/span><span style=\"font-weight: 400; color: #339966;\"># ls -l<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400; color: #000000;\">toplam 120<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\">drwx&#8212;&#8212; 6 999 adm\u00a0 4096 Nis 17 19:54 base<\/span><br \/>\n<span style=\"color: #000000;\">drwx&#8212;&#8212; 2 999 adm\u00a0 4096 Nis 21 03:38 global<\/span><br \/>\n<span style=\"color: #000000;\">drwx&#8212;&#8212; 2 999 adm\u00a0 4096 Nis 17 19:52 pg_commit_ts<\/span><br \/>\n<span style=\"color: #000000;\">drwx&#8212;&#8212; 2 999 adm\u00a0 4096 Nis 17 19:52 pg_dynshmem<\/span><br \/>\n<span style=\"color: #000000;\">-rw&#8212;&#8212;- 1 999 adm\u00a0 4535 Nis 17 19:52 pg_hba.conf<\/span><br \/>\n<span style=\"color: #000000;\">-rw&#8212;&#8212;- 1 999 adm\u00a0 1636 Nis 17 19:52 pg_ident.conf<\/span><br \/>\n<span style=\"color: #000000;\">drwx&#8212;&#8212; 4 999 adm\u00a0 4096 Nis 21 03:42 pg_logical<\/span><br \/>\n<span style=\"color: #000000;\">drwx&#8212;&#8212; 4 999 adm\u00a0 4096 Nis 17 19:52 pg_multixact<\/span><br \/>\n<span style=\"color: #000000;\">drwx&#8212;&#8212; 2 999 adm\u00a0 4096 Nis 21 03:37 pg_notify<\/span><br \/>\n<span style=\"color: #000000;\">drwx&#8212;&#8212; 2 999 adm\u00a0 4096 Nis 17 19:52 pg_replslot<\/span><br \/>\n<span style=\"color: #000000;\">drwx&#8212;&#8212; 2 999 adm\u00a0 4096 Nis 17 19:52 pg_serial<\/span><br \/>\n<span style=\"color: #000000;\">drwx&#8212;&#8212; 2 999 adm\u00a0 4096 Nis 17 19:52 pg_snapshots<\/span><br \/>\n<span style=\"color: #000000;\">drwx&#8212;&#8212; 2 999 adm\u00a0 4096 Nis 21 03:37 pg_stat<\/span><br \/>\n<span style=\"color: #000000;\">drwx&#8212;&#8212; 2 999 adm\u00a0 4096 Nis 21 07:18 pg_stat_tmp<\/span><br \/>\n<span style=\"color: #000000;\">drwx&#8212;&#8212; 2 999 adm\u00a0 4096 Nis 17 19:52 pg_subtrans<\/span><br \/>\n<span style=\"color: #000000;\">drwx&#8212;&#8212; 2 999 adm\u00a0 4096 Nis 17 19:52 pg_tblspc<\/span><br \/>\n<span style=\"color: #000000;\">drwx&#8212;&#8212; 2 999 adm\u00a0 4096 Nis 17 19:52 pg_twophase<\/span><br \/>\n<span style=\"color: #000000;\">-rw&#8212;&#8212;- 1 999 adm \u00a0 \u00a0 3 Nis 17 19:52 PG_VERSION<\/span><br \/>\n<span style=\"color: #000000;\">drwx&#8212;&#8212; 3 999 adm\u00a0 4096 Nis 17 19:52 pg_wal<\/span><br \/>\n<span style=\"color: #000000;\">drwx&#8212;&#8212; 2 999 adm\u00a0 4096 Nis 17 19:52 pg_xact<\/span><br \/>\n<span style=\"color: #000000;\">-rw&#8212;&#8212;- 1 999 adm\u00a0 \u00a0 88 Nis 17 19:52 postgresql.auto.conf<\/span><br \/>\n<span style=\"color: #000000;\">-rw&#8212;&#8212;- 1 999 adm 23963 Nis 17 19:52 postgresql.conf<\/span><br \/>\n<span style=\"color: #000000;\">-rw&#8212;&#8212;- 1 999 adm\u00a0 \u00a0 36 Nis 21 03:37 postmaster.opts<\/span><br \/>\n<span style=\"color: #000000;\">-rw&#8212;&#8212;- 1 999 adm\u00a0 \u00a0 94 Nis 21 03:37 postmaster.pid<\/span><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Zamanla baz\u0131 konteynerlerin kullan\u0131m\u0131 durabilir. <\/span><i><span style=\"font-weight: 400;\">Docker container rm<\/span><\/i><span style=\"font-weight: 400;\"> komutunu kullanarak bir konteyneri sildi\u011fimizde bu konteynerin kulland\u0131\u011f\u0131 volume\u2019\u00fcn silinmedi\u011fini s\u00f6ylemi\u015ftik. Diskte yer i\u015fgal eden, herhangi bir konteyner taraf\u0131ndan kullan\u0131lmayan tan\u0131mlanm\u0131\u015f volume\u2019lerin tamam\u0131n\u0131 temizlemek i\u00e7in en k\u0131sa yol<\/span><i><span style=\"font-weight: 400;\"> docker volume prune<\/span><\/i><\/span><span style=\"font-weight: 400;\"><span style=\"color: #000000;\"> komutudur. Bu sayede kullan\u0131lmayan t\u00fcm data volume\u2019leri tek komutla silinerek diskte yer a\u00e7\u0131labilir.<\/span> <\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">[omen _data]<\/span><span style=\"font-weight: 400; color: #339966;\"># docker volume ls\u00a0<\/span><\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">DRIVER\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 VOLUME NAME<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">local<\/span><span style=\"font-weight: 400;\"> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 f12cc8cf7eee61af18715ba70e16c9ea8fd167a175c3fbfbc32b9dd4f9ad8a2a<\/span><\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">[omen _data]<\/span><span style=\"font-weight: 400; color: #339966;\"># docker container rm -f wonderful_bassi <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">wonderful_bassi<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">[omen _data]<\/span><span style=\"font-weight: 400;\"># docker volume ls <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">DRIVER\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 VOLUME NAME<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">local<\/span><span style=\"font-weight: 400;\"> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 f12cc8cf7eee61af18715ba70e16c9ea8fd167a175c3fbfbc32b9dd4f9ad8a2a<\/span><\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">[omen _data]<\/span><span style=\"font-weight: 400;\"><span style=\"color: #339966;\"># docker volume prune<\/span> <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">WARNING! This will remove all <\/span><span style=\"font-weight: 400;\">local<\/span><span style=\"font-weight: 400;\"> volumes not used by at least one container.<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">Are you sure you want to <\/span><span style=\"font-weight: 400; color: #3366ff;\">continue<\/span><span style=\"font-weight: 400;\"><span style=\"color: #3366ff;\">?<\/span> [y\/N] y<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">Deleted Volumes:<\/span><\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">f12cc8cf7eee61af18715ba70e16c9ea8fd167a175c3fbfbc32b9dd4f9ad8a2a<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">Total reclaimed space: 40.54MB<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">[omen _data]<\/span><span style=\"font-weight: 400;\"><span style=\"color: #339966;\"># docker volume ls<\/span> <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">DRIVER\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 VOLUME NAME<\/span><\/span><\/p>\n<p><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">\u0130lk \u00f6rne\u011fimize d\u00f6nersek, pg11 konteynerimiz vard\u0131 ve bunu <\/span><b>-v pg11data:\/var\/lib\/postgresql\/data<\/b><span style=\"font-weight: 400;\"> etiketiyle ba\u015flatt\u0131\u011f\u0131m\u0131z i\u00e7in pg11data isimli bir data volume olu\u015fturmu\u015ftuk. Docker diskteki bu dizini konteyner i\u00e7indeki <\/span><b>\/var\/lib\/postgresql\/data<\/b><span style=\"font-weight: 400;\"> klas\u00f6r\u00fcne y\u00f6nlendirdi. B\u00f6ylece PostgreSQL konteynerinde olu\u015fan t\u00fcm datalar i\u00e7in diskimizde <\/span><b>\/var\/lib\/docker\/volumes\/pg11data<\/b><\/span><span style=\"font-weight: 400;\"><span style=\"color: #000000;\"> dizinini kullanmak istedi\u011fimizi belirtmi\u015f olduk. Bu klas\u00f6r\u00fc izleyebilir, yedekleyebilir ya da yeni bir konteyneri buraya ba\u011flayarak bu imaj \u00e7\u00f6kse dahi yeni bir PostgreSQL ile kald\u0131\u011f\u0131 yerden devam etmesini sa\u011flayabiliriz.<\/span> <\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">[profelis@profelis ~]$ docker volume ls <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">DRIVER\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 VOLUME NAME<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400; color: #3366ff;\">local<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0pg11data<\/span><\/span><\/p>\n<p><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Bir konteyneri \u00e7al\u0131\u015ft\u0131rmadan da imaj\u0131n kendi datalar\u0131n\u0131 hangi dizinde tutaca\u011f\u0131n\u0131 ilgili imaj\u0131n <\/span><b>Dockerfile<\/b><span style=\"font-weight: 400;\">\u2019\u0131n\u0131 inceleyerek g\u00f6rebiliriz. Bunun i\u00e7in Docker Hub\u2019da Postgres imaj sayfas\u0131nda tags sekmesine ge\u00e7erek \u00fczerinde \u00e7al\u0131\u015ft\u0131\u011f\u0131m\u0131z s\u00fcr\u00fcm etiketine t\u0131klayal\u0131m. \u015eu <\/span><a style=\"color: #000000;\" href=\"https:\/\/hub.docker.com\/layers\/postgres\/library\/postgres\/11\/images\/sha256-b05536a6dd641382a352b4d4706724cdfe83a55be70f5b477f34d9dc65a8faf9?context=explore\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">linkten<\/span><\/a><span style=\"font-weight: 400;\"> PostgreSQL:11 imaj\u0131n\u0131n Dockerfile\u2019\u0131na ula\u015fabilirsiniz. Dosyan\u0131n sonlar\u0131na do\u011fru VOLUME sat\u0131r\u0131nda PostgreSQL imaj\u0131 konteynerle\u015ftirildi\u011finde verilerini saklayaca\u011f\u0131 dizini belirtiyor.\u00a0<\/span><\/span><\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"color: #000000;\">Bir data volume tan\u0131mlayarak ba\u015flatt\u0131\u011f\u0131m\u0131z PostgreSQL 11 konteynerine girelim ve PostgreSQL k\u00fcmesine yeni bir veritaban\u0131 a\u00e7arak tablolar ve veriler ekleyelim. Sonras\u0131nda ise bu konteyneri durdurarak silelim. Bakal\u0131m verilere ne olacak?<\/span> <\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">[profelis@profelis ~]$ docker <\/span><span style=\"font-weight: 400; color: #3366ff;\">exec<\/span><span style=\"font-weight: 400;\"> -it pg11 bash <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">root@2b891069b8bb:\/<\/span><span style=\"font-weight: 400; color: #339966;\"># su &#8211; postgres<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">postgres@2b891069b8bb:~$ psql <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">psql (11.7 (Debian 11.7-2.pgdg90+1))<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">Type <\/span><span style=\"font-weight: 400; color: #339966;\">&#8220;help&#8221;<\/span> <span style=\"color: #3366ff;\"><span style=\"font-weight: 400;\">for<\/span> <span style=\"font-weight: 400;\">help<\/span><\/span><span style=\"font-weight: 400;\">.<\/span><\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"font-weight: 400; color: #000000;\">postgres=# \\l<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0List of databases<\/span><br \/>\n<span style=\"color: #000000;\">\u00a0 Name\u00a0 \u00a0 |\u00a0 Owner \u00a0 | Encoding |\u00a0 Collate \u00a0 | \u00a0 Ctype\u00a0 \u00a0 |<\/span><br \/>\n<span style=\"color: #000000;\">&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\">\u00a0postgres\u00a0 | postgres | UTF8 \u00a0 \u00a0 | en_US.utf8 | en_US.utf8 |<\/span><br \/>\n<span style=\"color: #000000;\">template0 | postgres | UTF8 \u00a0 \u00a0 | en_US.utf8 | en_US.utf8 |<\/span><br \/>\n<span style=\"color: #000000;\">template1 | postgres | UTF8 \u00a0 \u00a0 | en_US.utf8 | en_US.utf8 |<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\">(3 rows)<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\">postgres=# <span style=\"color: #3366ff;\">create database<\/span> profelis;<\/span><br \/>\n<span style=\"color: #3366ff;\">CREATE DATABASE<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\">postgres=#\u00a0 \\c profelis ;<\/span><br \/>\n<span style=\"color: #000000;\">You are now connected to database &#8220;profelis&#8221; as user &#8220;postgres&#8221;.<\/span><br \/>\n<span style=\"color: #000000;\">profelis=# <span style=\"color: #3366ff;\">create table<\/span> departman(<span style=\"color: #3366ff;\">id serial, name text<\/span>);<\/span><br \/>\n<span style=\"color: #3366ff;\">CREATE TABLE<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\">profelis=#<\/span> <span style=\"color: #3366ff;\">insert into<\/span> <span style=\"color: #000000;\">departman<\/span> <span style=\"color: #3366ff;\">values<\/span> (<span style=\"color: #339966;\">1, &#8216;muhasebe&#8217;<\/span>), (<span style=\"color: #339966;\">2, &#8216;teknik&#8217;<\/span>), (<span style=\"color: #339966;\">3, &#8216;yonetim&#8217;<\/span>);<br \/>\n<span style=\"color: #3366ff;\">INSERT<\/span> <span style=\"color: #000000;\">0 3<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\">profelis=#<\/span> <span style=\"color: #3366ff;\">select<\/span> * <span style=\"color: #3366ff;\">from<\/span> <span style=\"color: #000000;\">departman;<\/span><br \/>\n<span style=\"color: #000000;\">id | \u00a0 name \u00a0 <\/span><br \/>\n<span style=\"color: #000000;\">&#8212;-+&#8212;&#8212;&#8212;-<\/span><br \/>\n<span style=\"color: #000000;\">\u00a0 1 | muhasebe<\/span><br \/>\n<span style=\"color: #000000;\">\u00a0 2 | teknik<\/span><br \/>\n<span style=\"color: #000000;\">\u00a0 3 | yonetim<\/span><br \/>\n<span style=\"color: #000000;\">(3 rows)<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\">profelis=# \\q<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\">postgres@2b891069b8bb:~$<\/span> <span style=\"color: #3366ff;\">logout<\/span><br \/>\n<span style=\"color: #000000;\">root@2b891069b8bb:\/<\/span><span style=\"color: #993300;\"># exit<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\">[profelis@profelis ~]$ docker container stop pg11 <\/span><br \/>\n<span style=\"color: #000000;\">pg11<\/span><br \/>\n<span style=\"color: #000000;\">[profelis@profelis ~]$ docker container rm pg11 <\/span><br \/>\n<span style=\"color: #000000;\">pg11<\/span><\/p>\n<p><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">PostgreSQL 11 durduruldu ve diskten silindi. \u015eimdi PostgreSQL 11.7 konteynerini, ayn\u0131 klas\u00f6r\u00fc data volume olarak g\u00f6sterecek \u015fekilde ba\u015flataca\u011f\u0131z. Yani <\/span><b>ilk veritaban\u0131m\u0131zda olu\u015fturdu\u011fumuz verileri, PostgreSQL\u2019i upgrade etti\u011fimizde hala g\u00f6rmeyi<\/b><span style=\"font-weight: 400;\"> bekliyoruz.<\/span><\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">[profelis@profelis ~]$ docker run &#8211;name pg117 -d -e POSTGRES_PASSWORD=pass -v pg11data:\/var\/lib\/postgresql\/data postgres:11.7<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">Unable to find image <\/span><span style=\"font-weight: 400; color: #339966;\">&#8216;postgres:11.7&#8217;<\/span><span style=\"font-weight: 400;\"> locally<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">11.7: Pulling from library\/postgres<\/span><\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Digest: sha256:32f2b2b831bcc5318183eb09915c97552f7c2a9657b225f9ea0d23ed727271bb<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">Status: Downloaded newer image <\/span><span style=\"font-weight: 400; color: #3366ff;\">for<\/span><span style=\"font-weight: 400;\"> postgres:11.7<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">514d87da4305b895c044df3612b801dfb079ac84f2333055b0105fd8c09aab3c<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"font-weight: 400; color: #000000;\">[profelis@profelis ~]$ docker container ls -a<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<p style=\"font-size: 13px; padding-left: 40px;\"><span style=\"color: #000000;\">CONTAINER ID\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0IMAGE\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0COMMAND\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 CREATED\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0STATUS\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0PORTS\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0NAMES<\/span><br \/>\n<span style=\"color: #000000;\">2b891069b8bb\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 postgres:11\u00a0 \u00a0 \u00a0 \u00a0<span style=\"color: #339966;\"> &#8220;docker-entrypoint.s&#8230;&#8221;<\/span>\u00a0 \u00a0 43 seconds ago\u00a0 \u00a0 \u00a0 \u00a0Up 42 seconds\u00a0 \u00a0 \u00a0 5432\/tcp\u00a0 \u00a0 \u00a0 \u00a0 pg117<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">[profelis@profelis ~]$ docker <\/span><span style=\"font-weight: 400; color: #3366ff;\">exec<\/span><span style=\"font-weight: 400;\"> -ti pg117 bash <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">root@514d87da4305:\/<\/span><span style=\"font-weight: 400; color: #993300;\"># su &#8211; postgres<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">postgres@514d87da4305:~$ psql <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">psql (11.7 (Debian 11.7-2.pgdg90+1))<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">Type <\/span><span style=\"font-weight: 400; color: #339966;\">&#8220;help&#8221;<\/span> <span style=\"font-weight: 400;\">for<\/span> <span style=\"font-weight: 400;\">help<\/span><span style=\"font-weight: 400;\">.<\/span><\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">postgres=# \\l<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 List of databases<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"> \u00a0 Name\u00a0 \u00a0 |\u00a0 Owner \u00a0 | Encoding |\u00a0 Collate \u00a0 | \u00a0 Ctype\u00a0 \u00a0 | \u00a0 privileges \u00a0 <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"> postgres\u00a0 | postgres | UTF8 \u00a0 \u00a0 | en_US.utf8 | en_US.utf8 | <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"> profelis\u00a0 | postgres | UTF8 \u00a0 \u00a0 | en_US.utf8 | en_US.utf8 | <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"> template0 | postgres | UTF8 \u00a0 \u00a0 | en_US.utf8 | en_US.utf8 | \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"> template1 | postgres | UTF8 \u00a0 \u00a0 | en_US.utf8 | en_US.utf8 |\u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">(4 rows)<\/span><\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"font-weight: 400;\">postgres=# \\c profelis <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">You are now connected to database &#8220;profelis&#8221; as user &#8220;postgres&#8221;.<\/span><\/p>\n<p style=\"padding-left: 40px;\"><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">profelis=# <\/span><span style=\"font-weight: 400; color: #3366ff;\">select<\/span><span style=\"font-weight: 400;\"> * <\/span><span style=\"font-weight: 400; color: #3366ff;\">from<\/span><span style=\"font-weight: 400;\"> departman;<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"> id | \u00a0 name \u00a0 <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">&#8212;-+&#8212;&#8212;&#8212;-<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 1 | muhasebe<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 2 | teknik<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 3 | yonetim<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">(3 rows)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #000000;\">Burada fark\u0131ndaysan\u0131z PostgreSQL \u00fczerinde k\u00fc\u00e7\u00fck bir g\u00fcncelleme i\u015flemini Docker konteynerlerinin bize sundu\u011fu yap\u0131 sayesinde yapm\u0131\u015f olduk. PostgreSQL \u00f6zelinde b\u00fcy\u00fck s\u00fcr\u00fcm de\u011fi\u015fikliklerini (PostgreSQL 10\u2019dan 11\u2019e gibi) bu \u015fekilde yapmam\u0131z m\u00fcmk\u00fcn de\u011fil. \u00c7\u00fcnk\u00fc b\u00fcy\u00fck s\u00fcr\u00fcm de\u011fi\u015fikliklerinde PostgreSQL\u2019in dahili dosya depolama format\u0131 da (muhtemelen) de\u011fi\u015ftirildi\u011fi i\u00e7in yaln\u0131z veri dizini de\u011fil, PostgreSQL\u2019in yap\u0131s\u0131 da farkl\u0131l\u0131k g\u00f6sterecektir. PostgreSQL\u2019de bu t\u00fcr ana s\u00fcr\u00fcm g\u00fcncellemelerinde resmi dok\u00fcmantasyonu da esas alarak farkl\u0131 ara\u00e7lar ve y\u00f6ntemlerle s\u00fcr\u00fcm g\u00fcncelleme s\u00fcrecini tamamlayabilirsiniz.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"color: #000000;\">Yaz\u0131n\u0131n sonuna geldi\u011fimizde art\u0131k Docker\u2019\u0131n diskte kulland\u0131\u011f\u0131 alan\u0131 nas\u0131l bulaca\u011f\u0131m\u0131z\u0131 ve PostgreSQL \u00f6zelinde bu alandaki verileri nas\u0131l kullanabilece\u011fimizi biliyoruz. Sonraki yaz\u0131da Docker network komutlar\u0131na bakaca\u011f\u0131z. Yaz\u0131 dizimizi takip edin!<\/span> <\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yaz\u0131 dizimize Docker \u00fczerinde PostgreSQL ve PgAdmin kurulumuyla ba\u015flam\u0131\u015ft\u0131k. Devam\u0131nda ise Docker\u2019da \u00f6nemli bir di\u011fer konu olan volume y\u00f6netimini inceleyece\u011fiz. Bunun i\u00e7in i\u015fe PostgreSQL 11 imaj\u0131n\u0131 \u00e7al\u0131\u015ft\u0131rarak ba\u015flayaca\u011f\u0131z. Ba\u015fka bir s\u00fcr\u00fcmle ba\u015flamay\u0131n \u00e7\u00fcnk\u00fc yaz\u0131n\u0131n devam\u0131nda verilerimizi bozmadan PostgreSQL 11.7\u2019ye g\u00fcncelleyece\u011fiz&#8230;.<\/p>","protected":false},"author":11,"featured_media":22104,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43,75,45],"tags":[58,48,60,50],"class_list":["post-22013","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-haber","category-postgresql","category-yazi","tag-acikkaynak","tag-enterprisedb","tag-postgresql","tag-veritabani"],"_links":{"self":[{"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/posts\/22013","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/comments?post=22013"}],"version-history":[{"count":0,"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/posts\/22013\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/media\/22104"}],"wp:attachment":[{"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/media?parent=22013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/categories?post=22013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/profelis.com.tr\/en\/wp-json\/wp\/v2\/tags?post=22013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}