Docker Volumes Explained (PostgreSQL example)

Поділитися
Вставка
  • Опубліковано 5 жов 2024
  • 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 роки тому +46

    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 роки тому +3

      Matthew Wiese LOL I LOVED IT!!! I am going to start using it!

  • @sany2k8
    @sany2k8 4 роки тому +5

    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.

  • @aubydauby
    @aubydauby 11 місяців тому

    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

  • @mattbillman4688
    @mattbillman4688 3 роки тому

    This guy's a natural teacher - thank you for the content! Made my life much easier.

  • @salmanmusa9930
    @salmanmusa9930 2 роки тому

    when ever I am looking for something and I see your video am excited that I have found what I am looking for

  • @Ali_Alhajji
    @Ali_Alhajji 4 роки тому +23

    how to remember tar flags:
    tar -xzf eXtract Ze Files.
    tar -czf Compress Ze Files.

  • @joaquinurruti2628
    @joaquinurruti2628 6 місяців тому

    Exactly what I was looking for and perfectly explained, thanks a lot!

  • @najisolayman
    @najisolayman 3 роки тому +1

    Hussein god bless u with this information

  • @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!!!

  • @okonkwo.ify18
    @okonkwo.ify18 2 роки тому

    This guy is funny. No dull moment with him lol

  • @islamsaied6484
    @islamsaied6484 2 роки тому

    thanks Hussein, its so simple and clear .

  • @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

  • @juansalcedo6428
    @juansalcedo6428 2 роки тому

    That's exactly what I was looking for, Thanks a lot.

  • @osazemeusen1091
    @osazemeusen1091 4 роки тому +1

    Sweet, Succinct and straight to the point

    • @hnasr
      @hnasr  4 роки тому

      Thanks 😊 docker is awesome. enjoy the content.

  • @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

  • @yousefpahang
    @yousefpahang 2 роки тому

    Keep on Hussein this is perfect !

  • @patriciokumagae6167
    @patriciokumagae6167 2 роки тому

    Super clear man! Thank you!

  • @mohameddiaa3037
    @mohameddiaa3037 2 роки тому

    Thanks hussein

  • @MainakKundu19
    @MainakKundu19 4 роки тому +1

    Very useful video

  • @OtRatsaphong
    @OtRatsaphong 4 роки тому +1

    Great video!! Thank you 😊

    • @hnasr
      @hnasr  4 роки тому

      Thanks for watching and for all your comments!!

  • @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?

  • @ammadkhan4687
    @ammadkhan4687 5 місяців тому

    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?

  • @НаильГилазиев
    @НаильГилазиев 3 роки тому +1

    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!

  • @rahul_bali
    @rahul_bali 3 роки тому +2

    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

  • @sergiimarchuk6405
    @sergiimarchuk6405 2 роки тому

    Thank you

  • @dudulofuu
    @dudulofuu 2 роки тому

    Well done bro!

  • @mohamedyoussef8835
    @mohamedyoussef8835 Рік тому

    Awesome video +++++++++++++++ 🙂

  • @russellbateman3392
    @russellbateman3392 2 роки тому +1

    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.

  • @LawZist
    @LawZist 4 роки тому +1

    Great video!

    • @hnasr
      @hnasr  4 роки тому

      Thanks for your support in all the videos I make 😊 One of the OG subs

  • @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?

  • @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 3 роки тому

    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?

  • @evans8245
    @evans8245 4 роки тому +1

    Awesome dude, but why not use docker-compose so as not to re-type lengthy commands ?

    • @hnasr
      @hnasr  4 роки тому +2

      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 4 роки тому

      Any idea when you plan to make a video on docker-compose ?

  • @ricardohincapie1537
    @ricardohincapie1537 3 роки тому

    Thanks!!!

  • @RodrigoQueiroz-z9y
    @RodrigoQueiroz-z9y 4 місяці тому

    The problem is when my volume dont have the rights permissions. Aways it come with only root permissions to write and read

  • @fahemzoldyck1729
    @fahemzoldyck1729 3 роки тому

    is it possible to use two named volumes in the same Postgres Container ?

  • @ephraiminsular6496
    @ephraiminsular6496 3 роки тому

    Can you track with git the files in the docker volumes? Will that be a good idea?

  • @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...

  • @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.

  • @ibrahimalshmrani8216
    @ibrahimalshmrani8216 4 роки тому

    how do make 2 postgres containers have shared volumes so any changes on one it will affect the other ?

    • @hnasr
      @hnasr  4 роки тому

      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.

  • @RuslanSkiraUkraine
    @RuslanSkiraUkraine 4 роки тому

    Could you please show the same with the docker container. I'm trying3 times and my db is empty without structure.

  • @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 4 роки тому

      @@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 4 роки тому

      @@abhisheksahu616 using WSL2?

  • @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