Skip to content

Latest commit

 

History

History
54 lines (37 loc) · 1.5 KB

README.md

File metadata and controls

54 lines (37 loc) · 1.5 KB

Demo 3

Introduction to Overlay2

Inspect the image with docker cli

sudo ls -l /var/lib/docker/overlay2
sudo ls -l /var/lib/docker/overlay2/l
docker inspect nginx:1.20-alpine | jq .[0].GraphDriver.Data.LowerDir | jq 'split(":")'
FIRST_LAYER=$(docker inspect nginx:1.20-alpine | jq .[0].GraphDriver.Data.LowerDir | jq 'split(":")' | jq -r .[-1])
sudo ls -la ${FIRST_LAYER%/diff}

Inspect the image with dive

alias dive="docker run -ti --rm  -v /var/run/docker.sock:/var/run/docker.sock wagoodman/dive"
dive nginx:1.20-alpine

Start a container and inspect the layers

CONTAINER_ID=$(docker run -d nginx:1.20-alpine)

docker inspect nginx:1.20-alpine | jq .[0].GraphDriver.Data
docker inspect $CONTAINER_ID | jq .[0].GraphDriver.Data

docker inspect nginx:1.20-alpine | jq .[0].GraphDriver.Data.LowerDir | jq 'split(":")'
docker inspect $CONTAINER_ID | jq .[0].GraphDriver.Data.LowerDir | jq 'split(":")'

SECOND_LAST=$(docker inspect $CONTAINER_ID | jq .[0].GraphDriver.Data.LowerDir | jq 'split(":")' | jq -r .[1])
sudo tree $SECOND_LAST

LAST=$(docker inspect $CONTAINER_ID | jq .[0].GraphDriver.Data.LowerDir | jq 'split(":")' | jq -r .[0])
sudo tree $LAST

MERGED=$(docker inspect $CONTAINER_ID | jq -r .[0].GraphDriver.Data.MergedDir)
sudo ls -la $MERGED

mount | grep overlay

docker exec $CONTAINER_ID touch newFile.txt
sudo ls -la $MERGED

docker rm -f $CONTAINER_ID

Navigation