From 83c6ab5eada2d17b334370e44d8f6ee9ba8f6bc2 Mon Sep 17 00:00:00 2001 From: vijayclouddevops <151009420+vijayclouddevops@users.noreply.github.com> Date: Sat, 4 Jan 2025 17:56:16 +0530 Subject: [PATCH] Update how-to-use-docker-volumes.md Add dokcer volume content --- docker/scenarios/how-to-use-docker-volumes.md | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docker/scenarios/how-to-use-docker-volumes.md b/docker/scenarios/how-to-use-docker-volumes.md index e69de29b..78f49c4d 100644 --- a/docker/scenarios/how-to-use-docker-volumes.md +++ b/docker/scenarios/how-to-use-docker-volumes.md @@ -0,0 +1,28 @@ +# why we use volume in docker containers +# In all containers has own logs if container crashed or exit from any reason the how we can troubleshoot bcz as we knows logs are in container to aviod these things +# we user external volumes so containers log can persists. + +To check volumes: + docker volume ls +# volumes are two types +1. Managed by docker called volume +# For Create volume + docker volume create volumename. +# to check volume location or mountion point + docker volume inspect volumename +# We cant attache any volume in running container so we need to create new container with volume + docker run -d -P --mount type=volume,src=volumename,target=/opt/toomcat/logs image:v1 + # now if we check mounting point all loged has captureed or stored + # targrt of logs can be different according to application or image build + +2. Managed by user called bind volume +# why we need bind volume +# because volume created by dokcer need sudo privladges to access this location to avoide such these conditons we use bind volume +# we will create a dir. in any location wehere we didnt need sudo privladges + + mkdir /home/ubuntu/Dlogos +# now only chanages in commad is + type=bind, src=/home/ubuntu/Dlogs +docker run -d -P --mount type=bind,src=/home/ubuntu/Dlogs,target=/opt/toomcat/logs image:v1 + +