DevOps Classroomnotes 18/Jun/2022

How Containers Work

Docker Image Layers and Containers

  • Every container created has one R/W Layer added
  • All the changes made by container are in R/W layer
    Preview
  • When we delete the container the R/W layer will be deleted where as the image (i.e. image layers stay in tact)
  • The data that is generated by the container (i.e. running application) will be lost if we delete the container.
  • Now lets assume we have created mysql in a container. All the db updates will be present in the Thin R/W layer and if we delete mysql contaier we loose all the changes i.e. we loose data
  • We need to have some way to preserve this data created by containers i.e. life time of the data should be independent of the container.
  • Refer Here for image layers & Refer Here for the concept of the impact of image layers
  • To preserve the data loss in the Thin R/W layer of a container docker has a concept of volumes

Docker Volumes

  • Lets create a nginx container
    Preview
  • Create some files
    Preview
  • Now Remove the container
    Preview
  • The data created is lost
  • To persist the data created by container in the Docker Host Docker has volumes
  • For managing volumes docker has docker volume subcommand
    Preview
  • Now lets create a volume
    Preview
  • Now lets create nginx container and attach this volume. Add some data
    Preview
  • Remove the container and inspect volume
    Preview
    Preview
  • Even after removing the container the data is not lost
  • Now lets create a new container by attaching the same volume
    Preview
  • We can use this volume to attach multiple containers and share it across containers
    Preview
  • Refer Here for the concept of docker volumes.

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

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

Please turn AdBlock off
Animated Social Media Icons by Acurax Wordpress Development Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube