How to solve "failed to mount: no such device" error with the docker daemon

How to solve "failed to mount: no such device" error with the docker daemon

In this article, we will go about solving this error, and also go over what causes the error in the first place.


The solution to this problem could be as simple as rebooting your system.

The problem is caused mostly when the kernel updates itself during a system update. In my case, I was on Arch Linux when I ran the command sudo pacman -Syu to start a system update.

Upon completing the update, an error came up on my screen when I tried to run docker .

I used the following command to check the docker daemon logs - (Only works for systemd-based distros)

sudo journalctl -xeu docker.service

This was the output -

The first error message says - msg="failed to mount overlay: no such device" storage-driver=overlay2

Let us try to understand what overlay is and what are Layers in the context of Docker containers.

Docker Layers

Containers were meant to be a better and more efficient alternative to VMs, the preferred solution for running applications in isolation. Individual VMs do not share any resources between them. Each VM has its own full-fledged operating system which creates its own file system. Even two VMs of the same operating system share nothing with each other. While this kind of setup also has its use cases, it's a waste of resources in our context. Containers solve this problem by sharing resources.

What is an image? It's a collection of filesystem layers and metadata. These layers are together run by Docker as a container. Containers are a running instance of an image. We can run multiple containers of the same image.

Docker implements a copy-on-write mechanism. Multiple containers share the same base system of the base image. The base directory of the image is read-only and all the changes are recorded in a different directory which is then layered on top of the base directory. The Overlay driver is used by Docker to implement it's layered file system. Layers can be shared across multiple running containers.

References :

Learn more about docker layers