How to Save Docker Data using Bind Mounts or Volumes

Поділитися
Вставка
  • Опубліковано 1 гру 2024

КОМЕНТАРІ • 52

  • @priyanshugupta3160
    @priyanshugupta3160 8 місяців тому +2

    the explanation was so good bro 🔥

  • @manojsinghnegi1565
    @manojsinghnegi1565 2 роки тому +6

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

  • @hardworkerbig
    @hardworkerbig Рік тому +4

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

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

  • @thewestindianboy
    @thewestindianboy 7 місяців тому

    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.

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

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

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

  • @suen-tech
    @suen-tech 10 місяців тому +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!

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

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

    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.

  • @natural8471
    @natural8471 7 місяців тому +1

    Thank kyou! Great tutorial!!!!

  • @maheshyarasi2939
    @maheshyarasi2939 16 днів тому

    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  13 днів тому

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

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

  • @MohaideenA
    @MohaideenA Місяць тому

    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  Місяць тому

      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.

  • @redwansikder3847
    @redwansikder3847 5 місяців тому +1

    It removed my confusion about volume and bind mount.

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

    nice tutorial

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

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

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

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

  • @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 Рік тому

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

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