Stale File Handles : Auto-Healing Docker Mounts after Network Storage Drops

Stale File Handles : Auto-Healing Docker Mounts after Network Storage Drops 图片 1

In the previous parts of this series, I detailed how I migrated a 10TB external media drive to OpenMediaVault (OMV) and decoupled my container configurations ( appdata ) from the primary host VM ( Docker Host ) by mounting them over NFS. That transition moved me closer to a 100% stateless and disposable Docker VM.

But this decoupled architecture introduced a new operational headache: the network storage drop.

Whenever the OMV storage VM rebooted for maintenance or the internal virtual network hiccuped, running containers lost connection to their directories. Even when the host host-mount recovered automatically, containers remained locked in a broken state in NZBGet, throwing a frustrating error: ESTALE (errno=116): Stale file handle.

Here's how I automated the detection and auto-healing of stale NFS mount points inside Docker container namespaces.

The Root Cause: Inode Mismatch

When a Docker container starts with a bind mount (e.g., mapping /mnt/Element10tb/data on the host to /data in the container), the Linux kernel binds the container's mount namespace to the specific filesystem inode identifier on the host.

If the NFS share drops and then reconnects:

The host re-establishes the connection and mounts the share, creating a new filesystem inode.

The running container is unaware of this change and continues pointing to the old, dead inode.

The application inside the container (e.g., Sonarr, Radarr, or NZBGet) throws a Stale file handle error on any disk access, displaying "Space Unknown" or failing file writes.

The storage remains completely broken for the application until the container namespace is restarted, forcing it to bind to the new host inode.

┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ OMV NAS │ │ Docker Host │ │ Docker Container│
│ (NFS Server) │ │ (VM Parent) │ │ (Namespace) │
└────────┬────────┘ └────────┬────────┘ └────────┬────────┘
│ │ │
│ 1. Mounts Share (Inode A) │ │
├──────────────────────────────>│ │
│ │ 2. Binds /d…

添加评论
点赞收藏
点踩分享查看原文
评论
?
参与讨论