Docker删除DEAD状态的容器时报错。

解决方法1

我使用的这个方法起作用了。

I had the following error when removing a dead container (docker 17.06.1-ce on CentOS 7):

Error response from daemon: driver "overlay" failed to remove root filesystem for <some-id>: 

remove /var/lib/docker/overlay/<some-id>/merged: device or resource busy

Here is how I fixed it:

1. Check which other processes are also using docker resources

$ grep docker /proc/*/mountinfo

which outputs something like this, where the number after /proc/ is the pid:

/proc/10001/mountinfo:179...

/proc/10002/mountinfo:149...

/proc/12345/mountinfo:159 149 0:36 / /var/lib/docker/overlay/...

2. Check the process name of the above pid

$ ps -p 10001 -o comm=

dockerd

$ ps -p 10002 -o comm=

docker-containe

$ ps -p 12345 -o comm=

nginx   <<<-- This is suspicious!!!

So, nginx with pid 12345 seems to also be using /var/lib/docker/overlay/..., which is why we cannot remove the related container and get the device or resource busy error. (See here for a discussion on how nginx shares the same mount namespace with docker containers thus prevents its deletion.)

3. Stop nginx and then I can remove the container successfully.

$ sudo service nginx stop

$ docker rm <container-id>

 

解决方法2

docker rm -f Error response from daemon: Driver overlay failed to remove root filesystem

docker 强制删除(rm -f)container时出现错误提示,实际上已经删掉了,但这个错误提示导致jenkins提示不稳定

[root@p2p ~]# docker rm -f garage-server-webapp-app

Error response from daemon: Driver overlay failed to remove root filesystem b2fc7bdebd8b502044b74ac295732978b6791bf17e73041102bc3c6bac652a43: remove /var/lib/docker/overlay/3aa8285f09944c5a942b1c10ca9b2d18d7275b90986133f7db4ad766eb99ceb0/merged: device or resource busy

实际上,吞掉这个错误就可以了

  1. docker stop server-webapp-center 1>/dev/null 2>&1 | exit 0  
  2. docker rm -f server-webapp-center 1>/dev/null 2>&1 | exit 0  

解决方法3

What helped for me is just creating the directories that are missing and them remove them:

mkdir /var/lib/docker/devicemapper/mnt/656cfd09aee399c8ae8c8d3e735fe48d70be6672773616e15579c8de18e2a3b3

mkdir /var/lib/docker/devicemapper/mnt/656cfd09aee399c8ae8c8d3e735fe48d70be6672773616e15579c8de18e2a3b3-init

docker rm 656cfd09aee399c8ae8c8d3e735fe48d70be6672773616e15579c8de18e2a3b3

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐