How to Save Docker Data using Bind Mounts or Volumes

Поделиться
HTML-код
  • Опубликовано: 1 фев 2025

Комментарии • 52

  • @joachimhans2944
    @joachimhans2944 2 года назад

    Perfect for me. Instead of reading documents I always love to "feel" it with some handson examples. It saved my time. Thanks

  • @hardworkerbig
    @hardworkerbig Год назад +4

    this is a very great video with a clear and concise explanation of volumes and bind mounts... the best one ever.

  • @uncledavys
    @uncledavys 9 месяцев назад

    I saw many videos, but your video finally settled my confusion. Many thanks.

  • @bjorn9131
    @bjorn9131 Год назад +2

    every tutorial should be like this. quick and well explained

    • @DatabaseStar
      @DatabaseStar  Год назад

      Thanks! Glad to hear it’s a good tutorial.

  • @jackq9197
    @jackq9197 2 года назад

    I have been searching a lot about this subject and what you did is the best one

  • @manojsinghnegi1565
    @manojsinghnegi1565 2 года назад +6

    perfect. time efficient and informative tutorial. no time wasting. keep it up 👍

  • @pbanta101
    @pbanta101 2 года назад +2

    Great Video ! ! !
    I too was confused by reading different google explanations. This video quickly and clearly explained the concepts. All the examples worked just fine on my machine - a linux machine.
    Thank You ! ! !

    • @DatabaseStar
      @DatabaseStar  2 года назад

      Thanks! I’m glad it was helpful!

  • @anoniem012
    @anoniem012 2 года назад +1

    Thank you man was looking for this, it cleared up confusion, may Allah bless you with Islaam.

    • @DatabaseStar
      @DatabaseStar  2 года назад +1

      Thanks! Glad you found it helpful.

  • @priyanshugupta3160
    @priyanshugupta3160 11 месяцев назад +2

    the explanation was so good bro 🔥

  • @svgenterprises1
    @svgenterprises1 Год назад

    Thank you so very much! you really helped me understand how containers use volumes and binds and what is happening setting up my YAML files.

  • @suen-tech
    @suen-tech Год назад +1

    So simple. Thank you.

  • @nishitkumar7650
    @nishitkumar7650 2 года назад +6

    You should post more videos on docker and kubernetes

    • @DatabaseStar
      @DatabaseStar  2 года назад +2

      Thanks, I have a few more Docker videos planned. Glad you like them!

  • @natural8471
    @natural8471 9 месяцев назад +1

    Thank kyou! Great tutorial!!!!

  • @jeytis72
    @jeytis72 Год назад

    very informative and clear, thanks. What if your computer host break completely? Whar are your backup strategies to save elsewhere either a bind mounts or volumes with your data inside?

    • @DatabaseStar
      @DatabaseStar  Год назад +1

      Good question. I’m not sure on the strategies for backups with this approach. I remember reading that docker shouldn’t be used for production databases and this was one reason.

  • @indylawi5021
    @indylawi5021 Год назад

    thank you for your efforts preparing this great and informative video. If I may, I have a question. how about connecting to an existing database server that is on a different machine/host outside of the Docker host? did you come across this use-case in your research. would appreciate your input on this. thx in advance.

    • @DatabaseStar
      @DatabaseStar  Год назад

      Glad you like the video! I'm not sure how to do that from within the Docker container, unfortunately. My Docker knowledge is small (but growing) but I'm not sure how to do that.

  • @maheshyarasi2939
    @maheshyarasi2939 2 месяца назад

    Thank you so much for this detailed video. I had one question. When I try to do the bind method my target is "/var/lib/postgresql/data" and I am getting a permission denied error:
    chmod: changing permissions of '/var/lib/postgresql/data': Operation not permitted
    It works if I choose any other location including "/var/lib/postgresql" but the data I wish to copy is inside data. Please let me know if you are familiar with this? Thank you again.

    • @DatabaseStar
      @DatabaseStar  2 месяца назад

      Oh that's a bit annoying. I'm not sure what the cause of this is or how to resolve it, unfortunately.

  • @dawidgrzeskow987
    @dawidgrzeskow987 2 года назад

    Great video Gentelman, sub and like for you, keep up with the good work, happy to be there

  • @mohamedyoussef8835
    @mohamedyoussef8835 2 года назад

    Awesome video +++++++++ thank you 🙂

  • @reallogic0
    @reallogic0 2 года назад

    nice tutorial

  • @spill1987
    @spill1987 2 года назад

    Great video, thanks very much. The --mount type=bind function and how it was working for you in the vid is exactly what I'm looking for but I can't seem to get it working for my windows folder (D:\test). I used --mount type=bind,source=//d/test,target=/opt/drupal so I could see and access what's inside the drupal folder. The command is executed successfully and the container is created, but won't work :( Any ideas on that?

    • @DatabaseStar
      @DatabaseStar  2 года назад

      Glad you liked the video!
      I'm not sure what would be causing that issue. My first guess would be something to do with the path that is used and how it's on Windows. But you said it executed successfully, so that may not be an issue.
      Docker offers some logs, which you can use to check for any issues. I don't remember the command for it, but it's on the website, so it may give you more information about your errors.

    • @spill1987
      @spill1987 2 года назад

      @@DatabaseStar Thanks for the hints! As I was doing some research, I found out that mapped volumes can be accessed through \\wsl$\docker-desktop-data\data\docker\volumes. I'm Windows + WSL2 (Ubuntu). So I used that instead of bind mounts. Thanks again for the vid which helped me get there.

  • @redwansikder3847
    @redwansikder3847 7 месяцев назад +1

    It removed my confusion about volume and bind mount.

  • @MohaideenA
    @MohaideenA 3 месяца назад

    Getting this error. [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.40-1.el9 started.
    chown: changing ownership of '/var/lib/mysql/': Permission denied
    chown: changing ownership of '/var/lib/mysql': Permission denied

    • @DatabaseStar
      @DatabaseStar  3 месяца назад

      Oh interesting. I’m guessing it’s happening because your current user does not have permission to write to the folder. I’m not sure how to resolve it unfortunately.

  • @bokkenka
    @bokkenka 2 года назад

    How would you copy a volume from a test server to a production server?

    • @DatabaseStar
      @DatabaseStar  2 года назад

      Good question. I'm not sure how, I would usually try to migrate the data and objects rather than the volume. Also, from what I've read, docker volumes aren't advised for production. But I've never done it so I'm not sure.

    • @rapidscampi
      @rapidscampi 2 года назад +2

      Find the container, identify the tmpfs volume it's using and its host path, then copy the contents into your desired bind mount directory:
      docker container list |grep mysql
      copy the container id
      docker inspect container |grep Source
      This will show the path of the volume on the host, something like this:
      /var/lib/docker/volumes/a1126aab5716c00898db30ba50458ab4f32d5b6249416165ef721102f7cc5333/_data
      navigate to the directory and copy the contents from there into your intended bind mount directory.
      However, it's worth noting that there's two types of volume mount - named volumes and tmpfs volumes. Ditch the CLI to run containers and use Docker Compose. It makes life a lot easier as you can keep your config. More pertinently you can specify named volumes in your yml file which do persist between restarts. Just create a docker-compose.yml file in an empty directory with the below contents:
      version: '3.8'
      services:
      db:
      image: mysql:8.0
      restart: always
      environment:
      - MYSQL_DATABASE=mydb
      - MYSQL_ROOT_PASSWORD=mauFJcuf5dhRMQrjj
      ports:
      - '3306:3306'
      volumes:
      - db:/var/lib/mysql #This tells your container to use a named volume called db
      volumes: #This section defines the volume that's referenced above
      db:
      then run "docker-compose up -d" and compose will pull the image, build the containers and create the volume.

  • @AbdulBasit-ib6by
    @AbdulBasit-ib6by 2 года назад

    How to persist data in postgres?
    I tried using this docker command, docker run --name learn_postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres --mount source=postgres-volume,target=/var/lib/postgresql/data -p 5432:5432
    but once I checked container status using docker ps -a
    I see exited my container just after creation.

    • @DatabaseStar
      @DatabaseStar  2 года назад

      That's a strange one. I remember this happening to me a couple of times while working with Docker. I think there's a way to view some kind of logs in docker so you can see some more information about why it exited. Could you try that? I think there's a docker command for it.