🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
In this quick guide, we're diving deep into the art of creating Docker Volumes, ensuring you have the hands-on knowledge required for effectively managing containerized application data.
Why Create Docker Volumes?
Data Persistence: Ensure data survives container terminations.
Performance: Volumes offer better I/O performance than other data storage methods in Docker.
Sharing Data: Facilitates data sharing between containers.
Backup and Migration: Easily back up or migrate data outside the container ecosystem.
Creating a Docker Volume
Use the following command to create a Docker Volume:
docker volume create VOLUME_NAMEFor instance, to create a volume named my_data_volume:
docker volume create my_data_volumeOutput:
my_data_volumeThe command's output confirms the creation by echoing back the name of the volume.
If a name is not specified, Docker generates a random name:
$ docker volume create
d7fb659f9b2f6c6fd7b2c796a47441fa77c8580a080e50fb0b1582c8f602ae2fAdding More Layers: Advanced Options
Docker offers several options to customize volume creation.
Specify a Driver:
Docker volumes can be created using various drivers. The default is local, but others like nfs or those provided by storage solutions like NetApp or EMC can be used.
$ docker volume create --driver=DRIVER_NAME my_custom_volume
my_custom_volumeAdd Labels:
Labels are a way to add metadata to your volumes.
$ docker volume create --label project=sample_project my_labeled_volume
my_labeled_volumeUse Volume Options:
Depending on the driver used, you can provide specific options. For instance, with the local driver, you can specify the location on the host:
$ docker volume create --opt type=tmpfs --opt device=tmpfs --opt o=size=100m,uid=1000 my_opt_volume
my_opt_volumeVerifying Your Creation
After creating a volume, you can verify its existence using:
docker volume lsThis command lists all volumes present on the Docker host.
Conclusion
In this guide, we have learned how to create a Docker volume, how to create a Docker volume with different options, and how to verify the created volume.
Related Volume Management Guides
My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:
Build REST APIs with Spring Boot 4, Spring Security 7, and JWT
[NEW] Learn Apache Maven with IntelliJ IDEA and Java 25
ChatGPT + Generative AI + Prompt Engineering for Beginners
Spring 7 and Spring Boot 4 for Beginners (Includes 8 Projects)
Available in Udemy for Business
Building Real-Time REST APIs with Spring Boot - Blog App
Available in Udemy for Business
Building Microservices with Spring Boot and Spring Cloud
Available in Udemy for Business
Java Full-Stack Developer Course with Spring Boot and React JS
Available in Udemy for Business
Build 5 Spring Boot Projects with Java: Line-by-Line Coding
Testing Spring Boot Application with JUnit and Mockito
Available in Udemy for Business
Spring Boot Thymeleaf Real-Time Web Application - Blog App
Available in Udemy for Business
Master Spring Data JPA with Hibernate
Available in Udemy for Business
Spring Boot + Apache Kafka Course - The Practical Guide
Available in Udemy for Business
Comments
Post a Comment
Leave Comment