Course contentsShow
← Linux
Lesson 1495 of 1,81913. Containerization Primitives and NamespacesFree lesson

Volume Drivers and Remote Storage

Integrate network-attached storage via mount-based volume plugins.

In this lesson, you will learn how to extend container storage beyond the local host disk by integrating network-attached storage (NAS) via mount-based volume plugins.

Beyond Local Ephemerality

While OverlayFS and bind mounts are excellent for local host filesystems, they fall short when containers require persistent, highly available data that survives host failure or scales across a cluster. To achieve this, Linux utilizes volume drivers that act as an abstraction layer between the container runtime and external storage protocols like NFS, iSCSI, or cloud-native block storage.

The Mechanism of Mount-based Plugins

The core concept is the volume plugin, a helper binary or service that intercepts volume lifecycle events (create, mount, unmount, remove). When a container requests a remote volume, the orchestrator triggers the plugin to perform a "prepared mount."

  1. Orchestration: The runtime identifies a request for a remote volume.
  2. Plugin Execution: The plugin communicates with the storage backend (e.g., establishing an iSCSI session or mounting an NFS export).
  3. Kernel Integration: The plugin executes the mount syscall, placing the remote storage at a specific path on the host.
  4. Namespace Injection: The runtime performs a bind mount of that host path into the container’s mount namespace.

This allows the container to treat a remote network share as if it were a local directory, without needing to know the complexities of the underlying network protocol.

Conceptual Workflow

Consider a simple abstraction of how a plugin manages an NFS export:

# 1. Plugin receives request to attach storage
# 2. Plugin handles the network handshake
mount -t nfs4 -o rw 192.168.1.50:/exports/data /var/lib/docker/volumes/my-app-data/_data

# 3. Runtime binds this host directory to the container's namespace
mount --bind /var/lib/docker/volumes/my-app-data/_data /proc/self/root/mnt/data

Because the remote filesystem is mounted at the host level before being bind-mounted into the container namespace, the container process benefits from the POSIX-compliant file operations provided by the network storage backend. This keeps the container agnostic of the network complexity while ensuring that data integrity and concurrency are managed by the storage driver.

Key Takeaway: Volume drivers decouple container storage from local host hardware by utilizing plugin-orchestrated mount syscalls to bridge remote network filesystems into the container’s isolated mount namespace.