Docker Volume

Topics 

  • What is and Why volume (data volume)? 
  • Add a volume 
  • Mount host directory as a volume 
  • Create a volume 
  • Volume container 
  • Backup, restore, and migrate volumes

What is and Why Volume? 

  • Containers are ephemeral 
    • Once a container is removed, it is gone along with data it created 
  • What about scenarios where you want the applications running inside the container to write to some files/data and then ensure that the data is still present even if the container is no longer runs or exists 
    • You are running an application that is generating data and it creates files or writes to a database and so on. Now, even if the container is removed and in the future you launch another container, you would like that data to still be there 
  • Volumes are designed to persist data, independent of the container’s lifecycle 
    • Docker therefore never automatically deletes volumes when you remove a container, nor will it “garbage collect” volumes that are no longer referenced by a container

You must have an active subscription to download PDF and Lab Zip of this course topic.Please click the "Subscribe" button or the "Login" button if you already have an account.