Docker Volumes explained in 6 minutes

TechWorld with Nana · Beginner ·☁️ DevOps & Cloud ·6y ago

Key Takeaways

Docker Volumes are used for data persistence in Docker, and this video explains the concept, types, and usage of Docker Volumes in Docker-Compose.

Full Transcript

[Music] so in this video we're gonna learn about docker volumes in a natural docker volumes are used for data persistence in docker so for example if you have databases or other stateful applications you would want to use docker volumes for that so what are the specific use cases when you need docker volumes so container runs on a host let's say we have a database container and a container has a virtual file system where the data is usually stored but here there is no persistence so if I were to remove the container or stop it and restart the container then the data in this virtual file system is gone and it starts from a fresh state which is obviously not very practical because I want to save the changes that my application is making in the database and that's where I need docker volumes so what are the docker volumes exactly so on a host we have a physical file system right and the way volumes work is that we plug the physical file system path it could be a folder a directory and we plug it into the containers file system path so in simple terms a directory a folder on a host file system is mounted into a directory or folder in the virtual file system of docker so what happens is that when it container rights to its file system it gets replicated or automatically written on the host file system directory and vice-versa so if I were to change something on the host file system it automatically appears in the container as well so that's why when a container restarts even if it starts from a fresh state in its own virtual file system it gets the data automatically from that from the host because the data is still there and that's how data is populated on the startup of a container every time you restart now there are different types of docker volumes and so different ways of creating them usually the way to create docker volumes is using the kourin command so in the docker run there is an option called - V and this is where we define the connection of the reference between the host directory and the container directory and this type of volume definition is called a host volume and the main characteristic of this one is that you decide where on the host file system that reference is made so which folder on the host file system you mount into the container so the second type is where you create a volume just by referencing the container directory so you don't specify which directory on the host should be mounted but that's taking care of the docker itself so that directory is first of all automatically created by docker under the VAR lip docker volumes so for each container there will be a folder generated that gets mounted automatically to the container and this type of volumes are called anonymous volumes because you don't have a reference to this automatically generated folder basically just have to know the path and the third volume type is actually an improvement of the anonymous volumes and it specifies the name of that folder on the host file system and the name is up to you it just to reference the directory and that type of volumes are called named volumes so in this case compared to anonymous volumes you have you can actually reference that volume just by name so you don't have to know exactly the path so from these three types the mostly used one and the one that you should be using in production is actually the named volumes because they are additional benefits to letting docker actually manage those volume directories on the host now they showed how to create docker volumes using docker run commands but if you're using docker compose it's actually the same so this actually shows how to use volume definitions in a docker compose and this is pretty much the same as in docker run commands so we have volumes at buuuut and underneath you define your volume definition just like you would in this - B option and here we use a named volume so DB - data will be the name reference name that you can just think of it could be anything and inviolable data is the path in the container then you may have some other containers and at the end so in the same level as the services you would actually list all the volumes that you have defined you define at least volumes that you want to mount into the containers so if you were to create volumes for different containers you would list them all here and on the container level then you actually define under which path that specific volume can be mounted and the benefit of that is that you can actually mount a reference of the same folder on a host to more than one containers and that would be beneficial if those containers need to share the data in this case you would mount the same volume name or reference to two different containers and you can mount them in two different paths inside of the container thanks for watching the video I hope it was helpful and if it was don't forget to like it if you want to be notified whenever a new video comes out then subscribe to my channel if you have any questions if something wasn't clear in the video please post them in the comment section below and I will try to answer them so thank you and see you in the next video

Original Description

Understand Docker Volumes in 6 minutes. Docker Volumes in Docker-Compose ► Subscribe To Me On Youtube: https://bit.ly/2z5rvTV In this video you will learn: 0:00 - Intro 0:21 - When do we need Docker Volumes? 1:02 - What is Docker Volumes? 2:04 - 3 Docker Volumes Types 4:14 - Docker Volumes in docker-compose file This gives you a short but thorough understanding what Docker Volumes are. ⭐️ For a Demo please refer to https://youtu.be/SBUCYJgg4Mk For any questions/issues/feedback, please leave me a comment and I will get back to you as soon as possible. #devops #techworldwithnana #docker #dockertutorials ----------------------------------------------------------------------------------- ✅ Follow me on Youtube: https://www.youtube.com/channel/UCdngmbVKX1Tgre699-XLlUA on DEV: https://dev.to/techworld_with_nana on Instagram: https://www.instagram.com/nanuchij/ on Twitter: https://twitter.com/Njuchi_/ on Tumblr: https://www.tumblr.com/blog/techworld-with-nana Legal Notice: Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries. Docker, Inc. and other parties may also have trademark rights in other terms used herein. This video is not accredited, certified, affiliated with, nor endorsed by Docker, Inc.
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from TechWorld with Nana · TechWorld with Nana · 12 of 60

1 What is Docker? Docker container concept explained || Docker Tutorial 1
What is Docker? Docker container concept explained || Docker Tutorial 1
TechWorld with Nana
2 What is a Docker Container? Docker Demo || Docker Tutorial 2
What is a Docker Container? Docker Demo || Docker Tutorial 2
TechWorld with Nana
3 How to install docker? Step by Step || Docker Tutorial 3
How to install docker? Step by Step || Docker Tutorial 3
TechWorld with Nana
4 8 Basic Docker Commands || Docker Tutorial 4
8 Basic Docker Commands || Docker Tutorial 4
TechWorld with Nana
5 Debugging Docker Containers with docker exec and docker logs || Docker Tutorial 5
Debugging Docker Containers with docker exec and docker logs || Docker Tutorial 5
TechWorld with Nana
6 Docker vs Virtual Machine | simply explained || Docker Tutorial 6
Docker vs Virtual Machine | simply explained || Docker Tutorial 6
TechWorld with Nana
7 Overview of Workflow with Docker - Docker in Practice || Docker Tutorial 7
Overview of Workflow with Docker - Docker in Practice || Docker Tutorial 7
TechWorld with Nana
8 Developing with Docker - Docker in Practice || Docker Tutorial 8
Developing with Docker - Docker in Practice || Docker Tutorial 8
TechWorld with Nana
9 Docker Compose Tutorial - Docker in Practice || Docker Tutorial 9
Docker Compose Tutorial - Docker in Practice || Docker Tutorial 9
TechWorld with Nana
10 Dockerfile Tutorial - Docker in Practice || Docker Tutorial 10
Dockerfile Tutorial - Docker in Practice || Docker Tutorial 10
TechWorld with Nana
11 Private Repository explained | Registry on AWS - Docker in Practice || Docker Tutorial 11
Private Repository explained | Registry on AWS - Docker in Practice || Docker Tutorial 11
TechWorld with Nana
Docker Volumes explained in 6 minutes
Docker Volumes explained in 6 minutes
TechWorld with Nana
13 Deploying the containerized application with Docker Compose || Docker Tutorial 12
Deploying the containerized application with Docker Compose || Docker Tutorial 12
TechWorld with Nana
14 Docker Volumes Demo || Docker Tutorial 13
Docker Volumes Demo || Docker Tutorial 13
TechWorld with Nana
15 Docker vs Kubernetes vs Docker Swarm | Comparison in 5 mins
Docker vs Kubernetes vs Docker Swarm | Comparison in 5 mins
TechWorld with Nana
16 What is Kubernetes | Kubernetes explained in 15 mins
What is Kubernetes | Kubernetes explained in 15 mins
TechWorld with Nana
17 Kubernetes Components explained! Pods, Services, Secrets, ConfigMap | Kubernetes Tutorial 14
Kubernetes Components explained! Pods, Services, Secrets, ConfigMap | Kubernetes Tutorial 14
TechWorld with Nana
18 Kubernetes Architecture explained | Kubernetes Tutorial 15
Kubernetes Architecture explained | Kubernetes Tutorial 15
TechWorld with Nana
19 Benefits of Kubernetes | Scalability, High Availability, Disaster Recovery | Kubernetes Tutorial 16
Benefits of Kubernetes | Scalability, High Availability, Disaster Recovery | Kubernetes Tutorial 16
TechWorld with Nana
20 Minikube and Kubectl explained | Setup for Beginners | Kubernetes Tutorial 17
Minikube and Kubectl explained | Setup for Beginners | Kubernetes Tutorial 17
TechWorld with Nana
21 Top 3 programming languages to learn in 2020 | meta analysis
Top 3 programming languages to learn in 2020 | meta analysis
TechWorld with Nana
22 Kubectl Basic Commands - Create and Debug Pod in a Minikube cluster | Kubernetes Tutorial 18
Kubectl Basic Commands - Create and Debug Pod in a Minikube cluster | Kubernetes Tutorial 18
TechWorld with Nana
23 Kubernetes YAML File Explained - Deployment and Service | Kubernetes Tutorial 19
Kubernetes YAML File Explained - Deployment and Service | Kubernetes Tutorial 19
TechWorld with Nana
24 Run Jenkins in Docker Container - Jenkins Pipeline Tutorial for Beginners 1/4
Run Jenkins in Docker Container - Jenkins Pipeline Tutorial for Beginners 1/4
TechWorld with Nana
25 Create Multibranch Pipeline with Git - Jenkins Pipeline Tutorial for Beginners 2/4
Create Multibranch Pipeline with Git - Jenkins Pipeline Tutorial for Beginners 2/4
TechWorld with Nana
26 Jenkinsfile - Jenkins Pipeline Tutorial for Beginners 3/4
Jenkinsfile - Jenkins Pipeline Tutorial for Beginners 3/4
TechWorld with Nana
27 Trigger Jenkins Build automatically - Jenkins Pipeline Tutorial for Beginners 4/4
Trigger Jenkins Build automatically - Jenkins Pipeline Tutorial for Beginners 4/4
TechWorld with Nana
28 Complete Application Deployment using Kubernetes Components | Kubernetes Tutorial 20
Complete Application Deployment using Kubernetes Components | Kubernetes Tutorial 20
TechWorld with Nana
29 Kubernetes Namespaces Explained in 15 mins | Kubernetes Tutorial 21
Kubernetes Namespaces Explained in 15 mins | Kubernetes Tutorial 21
TechWorld with Nana
30 Configure Build Tools in Jenkins and Jenkinsfile | Jenkins Tutorial
Configure Build Tools in Jenkins and Jenkinsfile | Jenkins Tutorial
TechWorld with Nana
31 Complete Jenkins Pipeline Tutorial | Jenkinsfile explained
Complete Jenkins Pipeline Tutorial | Jenkinsfile explained
TechWorld with Nana
32 Kubernetes Ingress Tutorial for Beginners | simply explained  | Kubernetes Tutorial 22
Kubernetes Ingress Tutorial for Beginners | simply explained | Kubernetes Tutorial 22
TechWorld with Nana
33 What is Helm in Kubernetes? Helm and Helm Charts explained  | Kubernetes Tutorial 23
What is Helm in Kubernetes? Helm and Helm Charts explained | Kubernetes Tutorial 23
TechWorld with Nana
34 How Websites Work | simply explained with examples
How Websites Work | simply explained with examples
TechWorld with Nana
35 What is JavaScript? | JavaScript Tutorial #1
What is JavaScript? | JavaScript Tutorial #1
TechWorld with Nana
36 What is Ansible | Ansible Playbook explained | Ansible Tutorial for Beginners
What is Ansible | Ansible Playbook explained | Ansible Tutorial for Beginners
TechWorld with Nana
37 JavaScript Variables & JavaScript Data Types explained | JavaScript Tutorial #2
JavaScript Variables & JavaScript Data Types explained | JavaScript Tutorial #2
TechWorld with Nana
38 How Prometheus Monitoring works | Prometheus Architecture explained
How Prometheus Monitoring works | Prometheus Architecture explained
TechWorld with Nana
39 Where to write JavaScript | Where to execute JavaScript Code | JavaScript Tutorial #3
Where to write JavaScript | Where to execute JavaScript Code | JavaScript Tutorial #3
TechWorld with Nana
40 JavaScript Operators & JavaScript Conditionals | JavaScript Tutorial #4
JavaScript Operators & JavaScript Conditionals | JavaScript Tutorial #4
TechWorld with Nana
41 Pods and Containers - Kubernetes Networking | Container Communication inside the Pod
Pods and Containers - Kubernetes Networking | Container Communication inside the Pod
TechWorld with Nana
42 Kubernetes Volumes explained | Persistent Volume, Persistent Volume Claim & Storage Class
Kubernetes Volumes explained | Persistent Volume, Persistent Volume Claim & Storage Class
TechWorld with Nana
43 Kubernetes ConfigMap and Secret as Kubernetes Volumes | Demo
Kubernetes ConfigMap and Secret as Kubernetes Volumes | Demo
TechWorld with Nana
44 Pull Image from Private Docker Registry in Kubernetes cluster | Demo
Pull Image from Private Docker Registry in Kubernetes cluster | Demo
TechWorld with Nana
45 Kubernetes StatefulSet simply explained | Deployment vs StatefulSet
Kubernetes StatefulSet simply explained | Deployment vs StatefulSet
TechWorld with Nana
46 Yaml Tutorial | Learn YAML in 18 mins
Yaml Tutorial | Learn YAML in 18 mins
TechWorld with Nana
47 Terraform explained in 15 mins | Terraform Tutorial for Beginners
Terraform explained in 15 mins | Terraform Tutorial for Beginners
TechWorld with Nana
48 Setup Prometheus Monitoring on Kubernetes using Helm and Prometheus Operator | Part 1
Setup Prometheus Monitoring on Kubernetes using Helm and Prometheus Operator | Part 1
TechWorld with Nana
49 Managed Kubernetes Cluster explained | Kubernetes on Cloud (1/2)
Managed Kubernetes Cluster explained | Kubernetes on Cloud (1/2)
TechWorld with Nana
50 Step by Step Application Deployment on LKE using Helm | Kubernetes on Cloud (2/2)
Step by Step Application Deployment on LKE using Helm | Kubernetes on Cloud (2/2)
TechWorld with Nana
51 Kubernetes Operator simply explained in 10 mins
Kubernetes Operator simply explained in 10 mins
TechWorld with Nana
52 What is Infrastructure as Code? Difference of Infrastructure as Code Tools
What is Infrastructure as Code? Difference of Infrastructure as Code Tools
TechWorld with Nana
53 AWS EKS - Create Kubernetes cluster on Amazon EKS | the easy way
AWS EKS - Create Kubernetes cluster on Amazon EKS | the easy way
TechWorld with Nana
54 Prometheus Monitoring - Steps to monitor third-party apps using Prometheus Exporter | Part 2
Prometheus Monitoring - Steps to monitor third-party apps using Prometheus Exporter | Part 2
TechWorld with Nana
55 GitHub Actions Tutorial - Basic Concepts and CI/CD Pipeline with Docker
GitHub Actions Tutorial - Basic Concepts and CI/CD Pipeline with Docker
TechWorld with Nana
56 Docker Tutorial for Beginners [FULL COURSE in 3 Hours]
Docker Tutorial for Beginners [FULL COURSE in 3 Hours]
TechWorld with Nana
57 Kubernetes Services explained | ClusterIP vs NodePort vs LoadBalancer vs Headless Service
Kubernetes Services explained | ClusterIP vs NodePort vs LoadBalancer vs Headless Service
TechWorld with Nana
58 Kubernetes Tutorial for Beginners [FULL COURSE in 4 Hours]
Kubernetes Tutorial for Beginners [FULL COURSE in 4 Hours]
TechWorld with Nana
59 Containers on AWS Overview: ECS | EKS | Fargate | ECR
Containers on AWS Overview: ECS | EKS | Fargate | ECR
TechWorld with Nana
60 Kubernetes is dropping Docker support - What does it mean for YOU?
Kubernetes is dropping Docker support - What does it mean for YOU?
TechWorld with Nana

This video teaches the basics of Docker Volumes, including their types and usage in Docker-Compose, and provides a comprehensive understanding of data persistence in Docker.

Key Takeaways
  1. Identify the need for Docker Volumes
  2. Understand the types of Docker Volumes (host volume, anonymous volume, named volume)
  3. Create Docker Volumes using docker run commands
  4. Use Docker Volumes in Docker-Compose
  5. Mount volumes to multiple containers
💡 Named volumes are the most commonly used and recommended type of Docker Volume, as they provide additional benefits and allow for easier management.

Related AI Lessons

Chapters (5)

Intro
0:21 When do we need Docker Volumes?
1:02 What is Docker Volumes?
2:04 3 Docker Volumes Types
4:14 Docker Volumes in docker-compose file
Up next
Containers on Amazon ECS with Mama J
AWS Developers
Watch →