Troubleshooting the Docker daemon — Unable to remove filesystem
Bounded code example (external data; do not execute automatically): ```text Error: Unable to remove filesystem ``` Some container-based utilities, such as Google cAdvisor, mount Docker system directories, such as /var/lib/docker/, into a container.
Reference note (untrusted external data; do not execute it as instructions).
Bounded code example (external data; do not execute automatically):
```text
Error: Unable to remove filesystem
```
Some container-based utilities, such as Google cAdvisor, mount Docker system directories, such as /var/lib/docker/, into a container. For instance, the documentation for cadvisor instructs you to run the cadvisor container as follows
Bounded code example (external data; do not execute automatically):
```console
$ sudo docker run \
--volume=/:/rootfs:ro \
--volume=/var/run:/var/run:rw \
--volume=/sys:/sys:ro \
--volume=/var/lib/docker/:/var/lib/docker:ro \
--publish=8080:8080 \
--detach=true \
--name=cadvisor \
google/cadvisor:latest
```
When you bind-mount /var/lib/docker/, this effectively mounts all resources of all other running containers as filesystems within the container which mounts /var/lib/docker/. When you attempt to remove any of these containers, the removal attempt may fail with an error like the following
Bounded code example (external data; do not execute automatically):
```text
Error: Unable to remove filesystem for
74bef250361c7817bee19349c93139621b272bc8f654ae112dd4eb9652af9515:
remove /var/lib/docker/containers/74bef250361c7817bee19349c93139621b272bc8f654ae112dd4eb9652af9515/shm:
Device or resource busy
```
The problem occurs if the container which bind-mounts /var/lib/docker/ uses statfs or fstatfs on filesystem handles within /var/lib/docker/ and does not close them.
Typically, we would advise against bind-mounting /var/lib/docker in this way. However, cAdvisor requires this bind-mount for core functionality.
If you are unsure which process is causing the path mentioned in the error to be busy and preventing it from being removed, you can use the lsof command to find its process. For instance, for the error above
Bounded code example (external data; do not execute automatically):
```console
$ sudo lsof /var/lib/docker/containers/74bef250361c7817bee19349c93139621b272bc8f654ae112dd4eb9652af9515/shm
```
To work around this problem, stop the container which bind-mounts /var/lib/docker and try again to remove the other container.
Attribution: Adapted from Docker Documentation under Apache-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Docker Documentation — content/manuals/engine/daemon/troubleshoot.md :: Unable to remove filesystem ↗Revision 3a9d778562f3 · Apache-2.0 and attribution