Storage
Storage in Docker
When we build a docker image and run the container, it gets split into two parts:

What if we want to persist this data? For example, if we have a database and preserve the data created by the container, we can create a persistent volume:

Mount options
There are two types of mounting volumes in docker:
Using the -v to mount a volume is an old way, use the --mount options which is more verbose and include more parameters:
-v to mount a volume is an old way, use the --mount options which is more verbose and include more parameters:Docker has different storage drivers to mount volumes:
You can specify the volume driver when running a docker container, for example to provision a volume from AWS EBS:

Container Storage Interface (CSI)
Volumes

Here is an example to configure AWS EBS volume as storage option for the volume:

Persistent Volumes
To create a PV:


Persistent Volume Claims
To create a PVC object definition:

When a PVC is deleted, what happens to the PV?
By default, the PV is set to retain, which keeps the PV but it can't be reused in other claims, other options include:
Key Takeaways
Lab:
Storage Classes
This can be done by creating a storage class object definition:

We must define the storageClassName in the pvc definition so it can use the storage class:
storageClassName in the pvc definition so it can use the storage class:
Next time a PVC is created:

You can create different storage classes each using a different disk:

Lab:
Slides
Last updated
