Module 9 Lesson 1: Volume Drivers and Types
·DevOps

Module 9 Lesson 1: Volume Drivers and Types

Master the data layer of Docker. Explore the different volume drivers and types, and learn how to choose the right storage strategy for your application's data.

Module 9 Lesson 1: Volume Drivers and Types

We know that Volumes are how we keep data alive. But not all volumes are created equal. Depending on where your app is running (on your laptop, a server, or the cloud), you need different Volume Drivers.

1. What is a Volume Driver?

A driver is the "Translator" between Docker and your physical storage.

  • local (Default): Saves files in a folder on your computer's hard drive.
  • sshfs: Saves files on a remote server over SSH.
  • aws-s3 / azure-file: Saves files directly to cloud storage.

2. Types of Mounts (Recap & Deep Dive)

A. Named Volumes

docker run -v my-data:/app/data

  • Docker creates a folder in a managed area (e.g., /var/lib/docker/volumes/).
  • Primary Use: Databases and internal app state.

B. Bind Mounts

docker run -v /home/user/my-code:/app

  • Maps a specific host path to a container path.
  • Primary Use: Development (hot-reloading).

C. Anonymous Volumes

docker run -v /app/data (Notice there is no name before the colon).

  • Docker creates a random name (like 47d2f...).
  • Primary Use: Temporary storage that needs to persist even if the container is restarted but not necessarily saved forever.

D. tmpfs Mounts (Linux Only)

docker run --tmpfs /app/temp

  • Saves files directly in RAM, not on disk.
  • Primary Use: High-performance temporary files or sensitive data that must NEVER be written to the hard drive.

3. Choosing the Right Type

GoalUse...
Max Performance (DB)Named Volume
Code EditingBind Mount
Sensitive/Temp Datatmpfs
Cloud PortabilityVolume Driver (e.g., RexRay)

4. The "Volume Plugin" Power

Plugins allow you to connect Docker to enterprise storage systems (NetApp, Pure Storage, etc.). This allows a container on "Server 1" to be deleted and restarted on "Server 2" while automatically "Re-attaching" its data drive from the central storage.


Exercise: The Driver Check

  1. Run docker info. Look for the "Storage Driver" and "Logging Driver" sections. What are they?
  2. List your volumes: docker volume ls.
  3. Choose one and run docker volume inspect <name>. What is the "Driver" listed there? (It should be local).
  4. Why would you use an Amazon S3 volume driver instead of just saving files to the local disk?
  5. What happens to the data in a tmpfs mount if your computer loses power?

Summary

Volumes are the "Hard Drives" of the container world. By understanding the different drivers and mount types, you can design a data layer that is fast, secure, and moves seamlessly from your laptop to the cloud.

Next Lesson: Naming and organizing: Named vs. anonymous volumes.

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn