DevOps Classroom notes 19/Sep/2026

Docker volume

  • defult container will have ephemeral storag. its have data only layer of docker image. on top of image or running conatiner storage will remove when container is removed

  • Probelms:

  1. Data loss — any data written inside the container (database files, uploads, logs) disappears when the container is deleted or recreated.
  2. No sharing between containers — two containers can’t easily access the same data.
  3. No easy backup/migration — data is locked inside the container’s writable layer, tied to that specific container.
  4. Poor performance for write-heavy workloads — the container’s writable layer (using storage drivers like overlay2) is slower for I/O-heavy operations than a mounted volume.

All the above problems will Volumes solve this by storing data outside the container’s lifecycle, on the host or in Docker-managed storage, so data persists independently of the container.

  • volume will help to create custom storage

docker_cheatsheet

Docker volume

docker volume create	Create a volume
docker volume inspect	Display detailed information on one or more volumes
docker volume ls	List volumes
docker volume prune	Remove unused local volumes
docker volume rm	Remove one or more volumes
docker volume update	Update a volume (cluster volumes only)

Types of docker volumes

  • Named volumes
  • Bind mounts
  • tmpfs mounts

Named volume

  • Docker create and manage storage location /var/lib/dokcer/volumes/ on your docker host
  • volume will be mount on specific location of my container

create volume

docker volume create mysql_data1
docker volume create mysql_logs

docker run --name some-mysql  -v mysql_data1:/var/lib/mysql -v mysql_data:/var/logs -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest

docker stop containerid
docker rm containerid

docker volume rm mysql_data1 
docker volume rm mysql_logs

Bind mounts

  • map data on specific location on you container local host
docker run --name some-mysql  -v /root/mysql:/var/lib/mysql  -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest

git clone https://github.com/spring-projects/spring-petclinic.git
cd spring-petclinic
docker run -it \
  --name maven-builder \
  -v "$PWD":/usr/src/mymaven \
  -w /usr/src/mymaven \
  maven:3.9-eclipse-temurin-17 \
  mvn clean package -DskipTests && echo "hello" > sample.txt

Task

  1. create volume and lunch oracle-xe and mount oracle data /usr/lib/oracle/xe/oradata/XE/

  2. create table and inser sample data

  3. rm container and create new container with same volume and check data

  4. user bind mount and run spring-petclinic package cmd

  5. add another echo cmd to create sample file

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube