containerd Snapshot Drivers
Snapshotters manage how container image layers are stored and mounted. Learn about overlayfs, native, devicemapper, zfs, btrfs, and how to choose the right driver for your workload.
Snapshotters (also called snapshot drivers) are the components in containerd that manage the storage of container image layers and container writable layers. They implement copy-on-write (CoW) filesystem technologies to efficiently store and mount container layers.
When you pull a container image, containerd unpacks each layer and stores it using the snapshotter. When you start a container, the snapshotter creates a writable layer on top of the read-only image layers. Each snapshot driver has different performance characteristics, storage requirements, and capabilities.
overlayfs
native
devicemapper
zfs
btrfs
overlay (legacy)
overlayfs is the default snapshot driver for containerd. It uses the Linux kernel's overlay filesystem to efficiently manage container layers. It provides excellent performance with minimal overhead.
# Check if overlayfs is supported
grep overlay /proc/filesystems
# Check d_type support (overlayfs requires d_type)
xfs_info /var/lib/containerd | grep ftype
# ftype=1 means d_type is supported
# Configure overlayfs in containerd
# /etc/containerd/config.toml
[plugins."io.containerd.snapshotter.v1.overlayfs"]
root_path = "/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs"
# View overlayfs mounts
mount | grep overlay
# Check overlayfs usage
du -sh /var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/
The native driver does not implement copy-on-write. Each layer is a complete copy of the parent layer. This consumes significant disk space but is useful for testing or filesystems that don't support CoW.
# Configure native snapshotter
[plugins."io.containerd.snapshotter.v1.native"]
root_path = "/var/lib/containerd/io.containerd.snapshotter.v1.native"
# Use native snapshotter
ctr image pull --snapshotter=native docker.io/library/nginx:alpine
# Check disk usage (warning: large!)
du -sh /var/lib/containerd/io.containerd.snapshotter.v1.native/
The zfs snapshotter uses ZFS datasets and clones to implement efficient container layering. It's an excellent choice for ZFS filesystems with built-in compression, deduplication, and snapshot features.
# Create ZFS pool for containerd
sudo zpool create -f dockerpool /dev/sdb
# Create ZFS dataset
sudo zfs create dockerpool/containerd
sudo zfs set mountpoint=/var/lib/containerd dockerpool/containerd
# Configure containerd to use zfs
[plugins."io.containerd.snapshotter.v1.zfs"]
root_path = "/var/lib/containerd/io.containerd.snapshotter.v1.zfs"
# Use zfs snapshotter
ctr image pull --snapshotter=zfs docker.io/library/nginx:alpine
# Check ZFS datasets
zfs list
zfs list -t snapshot
The btrfs snapshotter uses Btrfs subvolumes and snapshots to implement container layering. It's a good choice for Btrfs filesystems with built-in CoW features.
# Create Btrfs filesystem
sudo mkfs.btrfs /dev/sdb
sudo mount /dev/sdb /var/lib/containerd
# Configure containerd to use btrfs
[plugins."io.containerd.snapshotter.v1.btrfs"]
root_path = "/var/lib/containerd/io.containerd.snapshotter.v1.btrfs"
# Use btrfs snapshotter
ctr image pull --snapshotter=btrfs docker.io/library/nginx:alpine
# Check Btrfs subvolumes
sudo btrfs subvolume list /var/lib/containerd
The devicemapper driver uses thin provisioning to manage container layers. It was the default driver for Docker on CentOS/RHEL 7 but is now deprecated in favor of overlayfs.
# Configure devicemapper (deprecated)
[plugins."io.containerd.snapshotter.v1.devicemapper"]
root_path = "/var/lib/containerd/io.containerd.snapshotter.v1.devicemapper"
pool_name = "docker-thinpool"
# Check devicemapper status
sudo dmsetup table
# Important: devicemapper is deprecated. Use overlayfs instead.
# Check current snapshotter
ctr snapshot ls
containerd config dump | grep snapshotter
# Set default snapshotter in config.toml
[plugins."io.containerd.grpc.v1.cri".containerd]
snapshotter = "overlayfs"
# Use different snapshotter for specific operations
ctr image pull --snapshotter=overlayfs docker.io/library/nginx:alpine
ctr image pull --snapshotter=zfs docker.io/library/postgres:15
# Check snapshotter usage
ctr snapshot ls
ctr snapshot usage
- overlayfs: Best performance, low overhead. Recommended for most workloads.
- zfs: Good performance with additional features (compression, deduplication).
- btrfs: Good performance with built-in CoW and snapshot features.
- native: Poor performance, high disk usage. Only for testing.
- devicemapper: Fair performance, deprecated.
# Check disk space (common issue)
df -h /var/lib/containerd
# Clean up old snapshots
ctr snapshot rm $(ctr snapshot ls -q)
# Check snapshot mount points
mount | grep containerd
# Inspect a specific snapshot
ctr snapshot info
# View snapshot usage per namespace
for ns in $(ctr namespace ls -q); do
echo "=== Namespace: $ns ==="
ctr -n $ns snapshot ls
done
# Reset containerd storage (dangerous)
sudo systemctl stop containerd
sudo rm -rf /var/lib/containerd
sudo systemctl start containerd
Choosing the right snapshot driver is essential for performance and storage efficiency. overlayfs is the best choice for most users.