以 overlay 为例
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:
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:
The problem occurs if the container which bind-mounts
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: