Home Cloud The different types of Docker Storage Driver

The different types of Docker Storage Driver

by admin

When working with Docker, and for the docker dca exam, it is important to understand the types of docker storage driver available and how they are used.

What are Docker Storage Drivers ?

What is a docker storage driver ? It is the bit of software that allows you to write data to the writable layer of your Docker container.

Unless volumes are used, the data written will be lost once a container is deleted. As we are writing to a container, read and write performance will be lower when compared to reads and writes for the native file system.

Docker supports a number of different storage drivers. Selecting the one to use boils down to a number of things, such as which ones are supported by the kernel or OS you are running, which backing file system you are using, and performance.

Types of Docker Storage Driver

The following is a list of the types of docker storage driver which can be configured and their use case:

overlay2 – This is the preferred storage driver for all Linux distributions
aufs – Preferred driver for earlier versions of Docker, when running on an earlier version of Ubuntu.
devicemapper – Requires direct-lvm. Was the recommended driver for earlier versions of Centos and RHEL. Current versions support overlay2, which is the recommended driver.
btrfs – Used if this is the backing file system
zfs – Used if this is the backing file system
vfs – Used for testing purposes only.

More detailed information on these types of volume storage drivers can be found here.

Docker will automatically select the storage driver to be used by default, though it is possible to change it, should you have a reason to.

Note: overlay2 operates at the file level rather than the block level. This is good for memory usage but for write-heavy workloads, device mapper may be worth considering as it is a block-level driver.

To check what storage driver you are currently using you can use the ‘docker info’ command:

docker info | grep "Storage Driver"

On my Centos 7 system the driver being used is Devicemapper:

Storage Driver: devicemapper

Running the same command on my Ubuntu system results in the following:

Storage Driver: aufs

How to Change the Docker Storage Driver

It’s possible to set the storage driver by either providing a flag to the docker daemon which will be read when it starts up, or by editing the Docker daemon configuration file.

To use a flag to set Docker to start using the device mapper driver we can run the following on a Centos system:

sudo vi /usr/lib/systemd/system/docker.service

Then edit the ExecStart line, adding the –storage-driver device mapper flag:

docker storage driver

To set the storage driver using the daemon configuration file you can add the following block to sudo vi /etc/docker/daemon.json:

{
"storage-driver": "devicemapper"
}

Once done, restart Docker using:

sudo systemctl restart docker
sudo systemctl status docker

That’s it for this one. There will be some more posts on Docker storage and on the device mapper driver coming soon.

Useful Links and Resources

https://docs.docker.com/storage/storagedriver/select-storage-driver/https://docs.docker.com/storage/storagedriver/

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More