This practical session focuses on understanding Docker persistent storage mechanisms and complete image lifecycle management.
The lab demonstrates Docker volume creation, bind mounts, stateful container setup, container-to-image conversion, image backup, removal, restoration, and layer inspection using Docker Desktop on Windows.
docker volume create myvolume
docker volume ls
docker run -it -v myvolume:/data ubuntu bash
Inside container:
cd /data
echo "Nitanshu DevOps Lab 27 Jan" > file.txt
cat file.txt
exit
docker run -it -v myvolume:/data ubuntu bash
Inside container:
cd /data
cat file.txt
exit
mkdir C:\dockerdata
docker run -it -v C:\dockerdata:/app ubuntu bash
Inside container:
cd /app
echo "Bind Mount Test" > bind.txt
exit
Host Verification:
dir C:\dockerdata
docker run -it --name java_container ubuntu bash
Inside container:
apt update
apt install openjdk-17-jdk -y
java -version
exit
docker commit java_container myrepo/java-img
docker images
docker run -it myrepo/java-img bash
Inside container:
java -version
exit
docker save -o java-image-backup.tar myrepo/java-img
dir java-image-backup.tar
docker rmi myrepo/java-img
docker images
docker load -i java-image-backup.tar
docker images
docker history myrepo/java-img
cd DevOps-Lab-Assignments
mkdir "Class Practical 27 Jan"
cd "Class Practical 27 Jan"
notepad README.md
cd ..
git add .
git commit -m "Added Class Practical 27 Jan - Docker Volumes & Image Lifecycle"
git push
This lab demonstrates stateful container management using Docker volumes and bind mounts, along with full Docker image lifecycle operations including commit, save, remove, load, and history inspection.
It validates Docker’s capability to manage persistence, portability, and recovery in DevOps environments.