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 ! ! !
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.
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?
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.
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.
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.
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
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.
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?
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.
@@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.
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.
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.
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.
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.
the explanation was so good bro 🔥
Glad you think so!
perfect. time efficient and informative tutorial. no time wasting. keep it up 👍
Thanks!
this is a very great video with a clear and concise explanation of volumes and bind mounts... the best one ever.
Glad it was helpful!
Perfect for me. Instead of reading documents I always love to "feel" it with some handson examples. It saved my time. Thanks
Thanks, glad it was helpful!
I saw many videos, but your video finally settled my confusion. Many thanks.
Glad it was helpful!
every tutorial should be like this. quick and well explained
Thanks! Glad to hear it’s a good tutorial.
Thank you man was looking for this, it cleared up confusion, may Allah bless you with Islaam.
Thanks! Glad you found it helpful.
I have been searching a lot about this subject and what you did is the best one
Glad to hear it helped!
So simple. Thank you.
You're welcome!
You should post more videos on docker and kubernetes
Thanks, I have a few more Docker videos planned. Glad you like them!
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 ! ! !
Thanks! I’m glad it was helpful!
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.
Glad it was helpful!
Thank kyou! Great tutorial!!!!
You’re welcome!
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.
Oh that's a bit annoying. I'm not sure what the cause of this is or how to resolve it, unfortunately.
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?
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.
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.
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.
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
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.
It removed my confusion about volume and bind mount.
Good to hear!
nice tutorial
Thanks!
Awesome video +++++++++ thank you 🙂
Thanks!
Great video Gentelman, sub and like for you, keep up with the good work, happy to be there
Thanks!
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?
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.
@@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.
How would you copy a volume from a test server to a production server?
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.
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.
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.
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.