🚀 DevOps & SRE Certification Program 📅 Starting: 1st of Every Month 🤝 +91 8409492687 🔍 Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Docker Lab, Excercise & Assignment – 3 – Docker Volume

Simple Flow to Create Volume /john1


$ docker run -it -v /john1 busybox
$ cd john1
$ ls
$ touch file1
$ ls
CTRL + P + Q
$ docker ps

The volume is exist even you restarts.


$ docker restart cont_id
$ docker exec cont_id ls /john1

Lets build a image with predefined Volume


$ vi Dockerfile
FROM ubuntu
ADD file1 /john2/file
VOLUME /john2
CMD ["/bin/bash"]

$ docker build myimage1 .
$ docker images
$ docker run -it myimage1
$ ls

Mapping between Host Volume and Containers


$ docker run -it -v /home/vagrant/john3:/john3 myimage1
$ cd john3
$ ls 
$ touch file5
$ exit
$ cd john3
$ ls

Senario 1 – Read only File Systems


$ docker run -it -v /home/vagrant/john3:/john3 myimage1
$ cd /john3
$ vi filex.txt # Try to save it and observe the output

Senario 2 – Map the Specific files between Host and Containers


$ docker run -it -v ~/.bash_history:/.bash_history myimage1

Lets clean up containers for clean next lab


$ docker kill $(docker ps -q)
$ docker rm $(docker ps -aq)

Senario 3 – Lets run the container with volume from another container volume


$ docker run -it -d --name cont1 -v /VolX myimage1
$ docker run -it --name cont2 --volumes-from cont myimage1

Locating a volume


docker inspect image_name # Look for mount section

More referencehttps://docs.docker.com/engine/tutorials/dockervolumes/

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.