Docker Volume

Human –> Docker pull image –>Docker client –> RESTAPI –> docker Deamon (will check local Repo(/Var/lib/docker) – if there – do rest / if not there – Download repo from registry

Where image layers stored

Path – /var/lib/docker

storage – /overlay2

where image meta data stored

/var/lib/docker /image

Docker Volumn

Go to /Var/lib/docker/volumes

root@Jami:/home/jami/Docker# docker volumn ls

root@Jami:/home/jami/Docker# docker volume create dev
dev

root@Jami:/# docker run -itd -v dev:/opt/dev ubuntu
fc90bdeb9b516ea09b85e5b2420a8a1cfc768fd8a78371767c2078d267ffeea9

root@Jami:/var/lib/docker/volumes# pwd
/var/lib/docker/volumes
root@Jami:/var/lib/docker/volumes#

root@Jami:/var/lib/docker/volumes/dev/_data# pwd
/var/lib/docker/volumes/dev/_data
root@Jami:/var/lib/docker/volumes/dev/_data#

create file and its also present outside container under location /var/lib/docker/volumes/dev/_data

root@Jami:/var/lib/docker/volumes/dev/_data# docker exec fc90bdeb9b51 touch /opt/dev/file1
root@Jami:/var/lib/docker/volumes/dev/_data# ls
file1
root@Jami:/var/lib/docker/volumes/dev/_data# docker exec fc90bdeb9b51 touch /opt/dev/file2
root@Jami:/var/lib/docker/volumes/dev/_data# docker exec fc90bdeb9b51 touch /opt/dev/file3
root@Jami:/var/lib/docker/volumes/dev/_data# ls
file1 file2 file3

root@Jami:/var/lib/docker/volumes/dev/_data# docker exec fc90bdeb9b51 ls /opt/dev
file1
file2
file3

stop and remove container but data still persist

root@Jami:/var/lib/docker/volumes/dev/_data# docker stop fc90bdeb9b51
fc90bdeb9b51
root@Jami:/var/lib/docker/volumes/dev/_data# docker rm fc90bdeb9b51
fc90bdeb9b51
root@Jami:/var/lib/docker/volumes/dev/_data# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@Jami:/var/lib/docker/volumes/dev/_data# ls
file1 file2 file3
root@Jami:/var/lib/docker/volumes/dev/_data#

Mount this volumn other container

root@Jami:/var/lib/docker/volumes/dev/_data# docker run -itd -v dev:/opt/dev ubuntu
25c90130ad315c27cdf31fb85fbb2335cba8c7746bfbdbc849fad9f7b7dd1d9e
root@Jami:/var/lib/docker/volumes/dev/_data# ls
file1 file2 file3
root@Jami:/var/lib/docker/volumes/dev/_data# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
25c90130ad31 ubuntu “/bin/bash” 12 seconds ago Up 11 seconds zealous_blackburn
root@Jami:/var/lib/docker/volumes/dev/_data# docker exec 25c90130ad31 ls /opt/dev
file1
file2
file3
root@Jami:/var/lib/docker/volumes/dev/_data#

also can mount 2 volumn to one container

root@Jami:/var/lib/docker/volumes/dev/_data# docker run -itd -v dev:/opt/dev -v qa:/opt/jami ubuntu
6de4fe01ac443bcccc1df1ea62acb6124d55908e893b506676fb5a7c3686eea0
root@Jami:/var/lib/docker/volumes/dev/_data# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6de4fe01ac44 ubuntu “/bin/bash” 9 seconds ago Up 8 seconds objective_albattani
25c90130ad31 ubuntu “/bin/bash” 3 minutes ago Up 3 minutes zealous_blackburn

only one we can see if doing df -kh and other can see if going to path
root@Jami:/var/lib/docker/volumes/dev/_data# docker exec 6de4fe01ac44 df -kh
Filesystem Size Used Avail Use% Mounted on
overlay 24G 13G 11G 55% /
tmpfs 64M 0 64M 0% /dev
shm 64M 0 64M 0% /dev/shm
/dev/sda3 24G 13G 11G 55% /opt/dev
tmpfs 5.4G 0 5.4G 0% /proc/asound
tmpfs 5.4G 0 5.4G 0% /proc/acpi
tmpfs 5.4G 0 5.4G 0% /proc/scsi
tmpfs 5.4G 0 5.4G 0% /sys/firmware
root@Jami:/var/lib/docker/volumes/dev/_data# docker exec 6de4fe01ac44 ls /opt
dev
jami
root@Jami:/var/lib/docker/volumes/dev/_data#

Related Posts

Friendly Guide Explaining Network Function Virtualization NFV And Operation

Introduction Computers talk to each other across long cables every second. In the past, companies bought heavy metal boxes for every task. One metal box stopped internet…

Read More

Easy Web Publishing Secrets For Every Creator With BlogOrbix

Introduction Great thoughts pop into our heads each day, but too many folks keep them locked inside. People fear complex computer setups, expensive bills, and ugly website…

Read More

Friendly Tools For Managing Software-Defined Networks In CloudOps

Introduction Computers talk to each other across long digital roads. In the cloud, we build these roads using clever code. People call this magic software-defined networking. CloudOps…

Read More

Bright Sky Routes And Golden Wings BestPilotsNow

Introduction Looking into the wide open sky brings pure wonder. Little children gaze up as shiny wings flash in the bright sunlight. You might want to grab…

Read More

Smart Networks Shape The Future of SDN in CloudOps

Introduction Computers talk to each other across long cables and invisible waves. We call this big network system the web. Old networks used heavy plastic boxes and…

Read More

Fantastic Open Road Vacations And Easy Trips With MotoShare Japan

Introduction Sunshine, clear skies, and open streets make travelers smile. Two wheels let you zoom past long lines of cars. You see hidden gardens that tour buses…

Read More
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x