Docker Volumes Explained (PostgreSQL example)

  Рет қаралды 33,381

Hussein Nasser

Hussein Nasser

4 жыл бұрын

In this short video I discuss docker volumes and demonstrate how to use volumes with postgres instances. We will create a postgres docker container, create some tables, backup our volume, destroy the container and spin up a brand new container with our existing volume.
#POSTGRES
docker run -p 5432:5432 --name pg -e POSTGRES_PASSWORD=postgres postgres
#PGADMIN
docker run -e PGADMIN_DEFAULT_EMAIL="hussein” -e PGADMIN_DEFAULT_PASSWORD=“password” -p 5555:80 --name pgadmin dpage/pgadmin4
Enjoy
🏭 Software Architecture Videos
• Software Architecture
💾 Database Engineering Videos
• Database Engineering
🛰 Network Engineering Videos
• Network Engineering
🏰 Load Balancing and Proxies Videos
• Proxies
🐘 Postgres Videos
• PostgresSQL
🚢Docker
• Docker
🧮 Programming Pattern Videos
• Programming Patterns
🛡 Web Security Videos
• Web Security
🦠 HTTP Videos
• HTTP
🐍 Python Videos
• Python by Example
🔆 Javascript Videos
• Javascript by Example
👾Discord Server / discord
Support me on PayPal
bit.ly/33ENps4
Become a Patreon
/ hnasr
Stay Awesome,
Hussein

Пікірлер: 66
@matthewwiese6972
@matthewwiese6972 4 жыл бұрын
This is a wonderful video! You inspire me to keep pushing! A clever mnemonic (not my own) for remembering tar: czvf = create ze vucking file xzvf = xtract ze vucking file
@hnasr
@hnasr 4 жыл бұрын
Matthew Wiese LOL I LOVED IT!!! I am going to start using it!
@sany2k8
@sany2k8 3 жыл бұрын
Whenever you start showing hands-on demo, you became a legend to me, you are genius on explaining things but hands-on demo make you super special. Keep up your good work.
@mattbillman4688
@mattbillman4688 2 жыл бұрын
This guy's a natural teacher - thank you for the content! Made my life much easier.
@aubydauby
@aubydauby 8 ай бұрын
Let me tell you- when I looked this topic up and saw you had a video in the search results, I felt instant relief. Dare I say, excited
@salmanmusa9930
@salmanmusa9930 Жыл бұрын
when ever I am looking for something and I see your video am excited that I have found what I am looking for
@MrOmarlive11
@MrOmarlive11 3 жыл бұрын
Thank you Hussein for your explanation, I tended to use docker volume for the exact same case you mentioned in 12:10
@patriciokumagae6167
@patriciokumagae6167 Жыл бұрын
Super clear man! Thank you!
@islamsaied6484
@islamsaied6484 2 жыл бұрын
thanks Hussein, its so simple and clear .
@joaquinurruti2628
@joaquinurruti2628 3 ай бұрын
Exactly what I was looking for and perfectly explained, thanks a lot!
@juansalcedo6428
@juansalcedo6428 2 жыл бұрын
That's exactly what I was looking for, Thanks a lot.
@yousefpahang
@yousefpahang 2 жыл бұрын
Keep on Hussein this is perfect !
@najisolayman
@najisolayman 3 жыл бұрын
Hussein god bless u with this information
@osazemeusen1091
@osazemeusen1091 4 жыл бұрын
Sweet, Succinct and straight to the point
@hnasr
@hnasr 4 жыл бұрын
Thanks 😊 docker is awesome. enjoy the content.
@Ali_Alhajji
@Ali_Alhajji 4 жыл бұрын
how to remember tar flags: tar -xzf eXtract Ze Files. tar -czf Compress Ze Files.
@ryanleemartin7758
@ryanleemartin7758 3 жыл бұрын
haha dude that awesome.
@OtRatsaphong
@OtRatsaphong 3 жыл бұрын
Great video!! Thank you 😊
@hnasr
@hnasr 3 жыл бұрын
Thanks for watching and for all your comments!!
@Ma1efcent
@Ma1efcent 2 жыл бұрын
Very well explained, & clear communication, - so many tech videos are created by people who are very difficult to understand. Thank you! :) ATB
@okonkwo.ify18
@okonkwo.ify18 2 жыл бұрын
This guy is funny. No dull moment with him lol
@mohameddiaa3037
@mohameddiaa3037 2 жыл бұрын
Thanks hussein
@dudulofuu
@dudulofuu 2 жыл бұрын
Well done bro!
@LawZist
@LawZist 4 жыл бұрын
Great video!
@hnasr
@hnasr 4 жыл бұрын
Thanks for your support in all the videos I make 😊 One of the OG subs
@MainakKundu19
@MainakKundu19 3 жыл бұрын
Very useful video
@IBITZEE
@IBITZEE 2 жыл бұрын
dude... when I'm searching for some topic video and I see one of yours... ;-) I already like it first and then proceed to see the video... LOL!!!
@sergiimarchuk6405
@sergiimarchuk6405 Жыл бұрын
Thank you
@ricardohincapie1537
@ricardohincapie1537 3 жыл бұрын
Thanks!!!
@mohamedyoussef8835
@mohamedyoussef8835 Жыл бұрын
Awesome video +++++++++++++++ 🙂
@AbdullahKhan-hz7yr
@AbdullahKhan-hz7yr 2 жыл бұрын
Another fantastic informative vid... quick question, or better still a follow up vid request... how to extend this to concept to my NAS drive, i.e. NFS storage?
@user-rp6zw3kb5w
@user-rp6zw3kb5w 3 жыл бұрын
Great video! can you research more advanced topic? best way to work with postgres data migrations. When you have postgres db in one container and backend app on other container. Backend app on java (ktor or vertx or other lightweight backend framework even in pure netty) 1) What the best way to initialize initial database structure with all required extensions(ex timescaledb) 2) What the best way to migrate database data structure while your project evolving Thanks!
@zickonezero
@zickonezero Жыл бұрын
👏🏻
@dorota7356
@dorota7356 3 жыл бұрын
For me, the data is correctly restored even after running 'docker -rm , but the backup files are not visible on the host or in the container. Anyone has an idea why?
@ammadkhan4687
@ammadkhan4687 2 ай бұрын
Hi Hussein, you are better than uni professor. Thanks for the video. I am wondering if it is possible to attach this volume of data to more than one postgres container for load balancing?
@tsiroukismichael9606
@tsiroukismichael9606 3 жыл бұрын
Hi Hussein. Congratulations for your great tutorials !!! After deciding to transfer my postgres with the persistant data from my Windows machine to a Linux machine (ubuntu 20.04) , i faced the following problem. I tranfered the tar file to the linux machine and untared it but without any luck. While trying to start running the postgres image with the persistant volume attached , the following error appears on the terminal . LOG: unrecognized configuration parameter "max_wal_size" in file "/var/lib/postgresql/data/postgresql.conf" line 228 LOG: unrecognized configuration parameter "min_wal_size" in file "/var/lib/postgresql/data/postgresql.conf" line 229 FATAL: configuration file "/var/lib/postgresql/data/postgresql.conf" contains errors Also i tried with the unziped folder to check if there was any error on the compression/decompression of the folders. Also In this case i get the same error message? Is there any workaround on this ? Has anyone faced the same problem ?
@karapelerin61
@karapelerin61 2 жыл бұрын
Hi Hussein, Thanks for this video. If created a postgresql 9.5 container and add a volume /pg to it, and several days later created a new container for postgresql 10 and used same data volume /pg folder. Is there any problem for this operation?
@ephraiminsular6496
@ephraiminsular6496 3 жыл бұрын
Can you track with git the files in the docker volumes? Will that be a good idea?
@russellbateman3392
@russellbateman3392 Жыл бұрын
Good tutorial, but the PostgreSQL Docker container has changed, so you cannot easily follow along any more. You have to do stuff like add "--env POSTGRES_PASSWORD=password" to his command lines.
@fahemzoldyck1729
@fahemzoldyck1729 3 жыл бұрын
is it possible to use two named volumes in the same Postgres Container ?
@rahul_bali
@rahul_bali 3 жыл бұрын
Error: Database is uninitialized and superuser password is not specified. You must specify POSTGRES_PASSWORD to a non-empty value for the superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run". You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all connections without a password. This is *not* recommended. See PostgreSQL documentation about "trust": www.postgresql.org/docs/current/auth-trust.html
@ibrahimalshmrani8216
@ibrahimalshmrani8216 3 жыл бұрын
how do make 2 postgres containers have shared volumes so any changes on one it will affect the other ?
@hnasr
@hnasr 3 жыл бұрын
you can't, this is a bad idea. there might be a way to run postgres as read only even then the way the database locks files on disk . You can run one at a time but not two at the same time.
@evans8245
@evans8245 4 жыл бұрын
Awesome dude, but why not use docker-compose so as not to re-type lengthy commands ?
@hnasr
@hnasr 4 жыл бұрын
AudacityTunesE.T.C its a great idea for sure. I usually use technology that ai have explained in the channel. Since I still didn’t talk about compose I decided to go the simple route to explain things. Need to make the compose video that is a great idea! Thanks!
@evans8245
@evans8245 4 жыл бұрын
@@hnasr it's alright, I understand 👌
@86Saurabh1
@86Saurabh1 3 жыл бұрын
Any idea when you plan to make a video on docker-compose ?
@user-ds6wp2zo4x
@user-ds6wp2zo4x 28 күн бұрын
The problem is when my volume dont have the rights permissions. Aways it come with only root permissions to write and read
@MostafaZeinali
@MostafaZeinali 2 жыл бұрын
Great vid. Thanks. One question guys, on a linux server, what is a good place/path to map as the data folder? Should it be in the $user folder, or some path from / I'm asking this because I'm assuming changing the user's name should not affect how the container works, right?
@MostafaZeinali
@MostafaZeinali 2 жыл бұрын
Just off the top of my head, since PostgreSQL stores its data in /var/lib/postgresql/data, why not user /var/lib/postgresql/data/$container_name$ or something like that
@MostafaZeinali
@MostafaZeinali 2 жыл бұрын
The permissions might be the most important issue here...
@RuslanSkiraUkraine
@RuslanSkiraUkraine 3 жыл бұрын
Could you please show the same with the docker container. I'm trying3 times and my db is empty without structure.
@yaroslavgamretsky4388
@yaroslavgamretsky4388 3 жыл бұрын
Try to use docker start command
@DerekHuggens
@DerekHuggens 2 жыл бұрын
Hello Hussein, (I am on Windows) I have a Docker container setup with the newest PostgreSQL image and used the docker run command in this video. In Docker I can see the container is running and with docker ps I can see the container. Docker inspect on the Container ID shows everything looks great. However, in PgAdmin4 when I create a server: General Tab, server name: pg, Connection Tab: Port 5432, Maintenance Database is postgres, Username is postgres, Password is postgres, I cannot create the server because no "Host name/address" ever works! Yours is Husseinmac, but I do not know what mine is to get this working! Please advise, Thank You.
@hassanalbaruki8173
@hassanalbaruki8173 2 жыл бұрын
try: localhost
@YousufZiaTheOneAndOnly
@YousufZiaTheOneAndOnly 3 жыл бұрын
If you guys are interested in a node ts and postgres setup with docker you can checkout this blog: yzia2000.github.io/blog/2021/01/15/docker-postgres-node.html
@HungNguyen-lz5xb
@HungNguyen-lz5xb 2 жыл бұрын
this guy wrote tar with correct syntax in one try without googling....
@BhargavMurari
@BhargavMurari 4 жыл бұрын
This doesn't work on Windows machine docker till date for postgres.
@hnasr
@hnasr 4 жыл бұрын
Can you make sure you enabled linux container on docker for windows?
@BhargavMurari
@BhargavMurari 4 жыл бұрын
@@hnasr yeah, it is enabled. The error details are here. There is no direct volume mapping we can do in windows for postgres till date. forums.docker.com/t/data-directory-var-lib-postgresql-data-pgdata-has-wrong-ownership/17963
@BhargavMurari
@BhargavMurari 4 жыл бұрын
I mean volume mapping to my C:/postgrrs/data like that
@abhisheksahu616
@abhisheksahu616 3 жыл бұрын
@@BhargavMurari Works for me. I have enabled linux container on docker as well. docker run --name pg -p 5432:5432 -e POSTGRES_PASSWORD=postgres -v C:\Users\*******\Documents\postgres_v:/var/lib/postgresql/data postgres:10
@BhargavMurari
@BhargavMurari 3 жыл бұрын
@@abhisheksahu616 using WSL2?
БОЛЬШОЙ ПЕТУШОК #shorts
00:21
Паша Осадчий
Рет қаралды 8 МЛН
Wait for the last one! 👀
00:28
Josh Horton
Рет қаралды 127 МЛН
The effect of Random UUID on database performance
18:51
Hussein Nasser
Рет қаралды 68 М.
Migrate Docker Volumes from one Host to another // backup and restore
8:56
If you're not developing with this, you're wasting your time
14:30
Articulated Robotics
Рет қаралды 265 М.
Docker Crash Course #10 - Volumes
18:38
Net Ninja
Рет қаралды 65 М.
Connection Pooling in PostgresSQL with NodeJS (Performance Numbers)
12:01
How to create a great dev environment with Docker
29:55
Patrick Loeber
Рет қаралды 252 М.
Linux Servers. Docker #5. Volume и монтирование в контейнер
28:48
Docker Volumes Explained
7:55
WittCode
Рет қаралды 9 М.
Docker and PostgreSQL in [10 Minutes]
21:06
Amigoscode
Рет қаралды 265 М.
PostgreSQL CRASH COURSE - Learn PostgreSQL in 2022
50:26
Troy Amelotte
Рет қаралды 208 М.
Спутниковый телефон #обзор #товары
0:35
Product show
Рет қаралды 1,9 МЛН
Secret Wireless charger 😱 #shorts
0:28
Mr DegrEE
Рет қаралды 2,4 МЛН
Ультрабюджетная игровая мышь? 💀
1:00