A lovely low-level filesystem question!
Yes, I'd be happy to help.
The error message "overlayfs: upper fs missing required features" typically indicates that the filesystem you're trying to use as the upper layer (in your case, the virtiofs shared filesystem mounted at /var/lib/docker) doesn't support some features that OverlayFS requires.
OverlayFS is a union filesystem that allows you to layer multiple filesystems on top of each other. In Docker's case, it's used to create efficient, copy-on-write layers for containers. The OverlayFS setup requires:
- Lower layer (usually the image layers): can be any filesystem.
- Upper layer (where changes are written): must support certain features.
The required features for the upper layer filesystem are:
d_type (directory entry type): the ability to return the type of a directory entry (file, dir, symlink, etc.) via readdir(). This is crucial for OverlayFS to efficiently manage the union filesystem.
inode numbers stability: inode numbers shouldn't change across mounts (not a problem in most cases).
xattr (extended attributes) support: required for storing Docker metadata.
virtiofs, being a relatively new, high-performance shared filesystem for virtual machines (backed by the host's filesystem), has some limitations.
The problem: virtiofs currently does not support d_type (directory entry type) in its default configuration. This is the feature that's missing, causing the OverlayFS error.
Here are a few potential solutions:
1. Mount virtiofs with d_type support (if available):
Check if a newer version of virtiofs or your host's filesystem supports d_type. You can try mounting virtiofs with the -o d_type option (note: this might not work if the underlying host FS doesn't support it):
sudo umount /var/lib/docker
sudo mount -t virtiofs -o d_type your_shared_fs_name /var/lib/docker
Replace your_shared_fs_name with the actual name of your shared virtiofs (you can find it in /etc/mtab or /proc/mounts).
2. Use overlay2 with index=off (workaround):
You can configure Docker to use OverlayFS with index=off, which disables the use of d_type. This comes with a performance penalty, as OverlayFS will need to perform more stat() calls.
Edit or create the Docker daemon configuration file (/etc/docker/daemon.json):
{
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.index=off"
]
}
Then, restart the Docker daemon:
sudo systemctl restart docker
This should allow OverlayFS to work, albeit less efficiently.
3. Move Docker's data directory to a native filesystem (recommended):
If you have enough local storage on your VM, the best solution is to move Docker's data directory (/var/lib/docker) to a native, non-shared filesystem that supports d_type out of the box (e.g., ext4, XFS, btrfs). This will give you the best performance.
For example, you could:
- Create a new directory on a local disk (e.g.,
/docker-data).
- Stop Docker:
sudo systemctl stop docker.
- Move the data:
sudo mv /var/lib/docker /docker-data/.
- Symlink it back:
sudo ln -s /docker-data/docker /var/lib/docker.
- Start Docker again:
sudo systemctl start docker.
With this setup, OverlayFS will work flawlessly, and you'll avoid any shared filesystem limitations.
4. Consider using vfs driver (last resort):
If none of the above works, you can fall back to Docker's vfs storage driver (not recommended for production due to its slow performance, as it does full copies instead of copy-on-write):
{
"storage-driver": "vfs"
}
Restart Docker after making this change.
Verify OverlayFS is working:
After applying any solution, check Docker's info to confirm OverlayFS is in use:
docker info | grep Storage
It should output something like:
Storage Driver: overlay2
Hope one of these solutions works for you! If you're still stuck, provide more details about your VM setup, host filesystem, and virtiofs version. Good luck!