EMAIL SUPPORT

dclessons@dclessons.com

LOCATION

US

Docker Volume Deep-Dive

Docker Volume Deep-Dive

Volume & Persistence Data:

There are two types of Data, Persistence Data which is needed to be kept and is used in future, where as Non- Persistence data is one what in not required to be kept for long days.

Every Docker container has non-persistence storage, this type of storage is automatically created, and is tied to lifecycle of container. That means that if container is deleted, its tied storage is also deleted.

In this non-persistence storage all the container files and file systems are stored.

On Linux system, storage is exists under /var/lib/docker// as part of container.

Following are Linux drivers mentioned here

  • Red Hat Enterprise Linux: overlay 2 driver
  • Ubuntu: overlay2 or aufs driver
  • SUSE Linux Enterprise server: Btrfs storage driver
  • Windows: It has only driver that is configured by default.

Now if you need to keep data safe even after container is deleted, you need to create volume. These Volume are created and managed separately. Even you delete container, Volume is not automatically created, unless it is explicitly deleted.

Containers and Persistence Data

In this, you should create Volume and the create containers and then you should mount volume to your containers.

The volume gets mounted to a directory in container file systems, and anything written to that directory gets written to volume and even after that container is deleted, the volume remains on docker host and your data is still safe.

Docker volume is mounted in to a container at /code. Any data written to /code directory will be stored on volume and will exits after container is deleted.

Create Docker Volume

Now let’s create Docker Volume, Commands to be run on docker host is given below figure.

Here we are creating docker volume whose name is dclessons-vol and once it is created, it can be viewed by docker volume ls command and you can even inspect this volume to see that on which directory it is mapped to.

In the above example it is attached to /var/lib/docker/volumes/dclessons-vol/_data


Comment

  • ST

    hi please check Providing Security in Docker is available


LEAVE A COMMENT

Please login here to comment.