DevOps Classroom notes 30/Jun/2025

Docker contd…

Docker Image Layers

  • Lets run the simple apline image with sleep 1d as cmd
  • Docker image is collection of readonly layers
  • Each docker container gets a writable layer for all changes done w.r.t storage and image layers are reused across containers
  • When we make any change in existing file which is part of image gets copied into writable layer and then modified (copy on write strategy)
  • When you delete the container writable layer is deleted.

How are layers getting created

  • Docker Image layers are create during image creation
  • Image automatically gets parent layers (FROM)
  • Any instruction that leads to change in storage will create a layer.
  • Having too many layers is not a good idea, layers are created for reusability.
  • On a broader note, the following instructions majorly lead to layer creation
    • RUN
    • ADD | COPY
  • Generally we club lots of commands in a RUN statement
RUN apt update && \
    apt install openjdk-17-jdk -y && \
    .... \
    ... \
    ... \

How does Docker deal with layers

  • Docker Storage drivers deal with layers and make them available as disks to container
  • Right now overlay2 is used in docker
  • refer the following articles

Example

  • Try finding a docker commad to run mysql container with
    • username: qtdevops
    • password: qtdevops
    • database: qtlms
docker run -d --name db \
    -e MYSQL_ROOT_PASSWORD=qtdevops \
    -e MYSQL_PASSWORD=qtdevops \
    -e MYSQL_USERNAME=qtdevops \
    -e MYSQL_DATABASE=qtlms \
    -p 3306:3306 \
    mysql:8.0
  • How to persist the data i.e. data should not be lost post container deletion => Volumes
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a comment

Turn on JavaScript to leave a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%