「 Docker」容器Removal In Progress删除方案

问题发生

有两个闲置的容器在删除时发生错误,处在Removal In Progress状态。在重启Docker后处于Dead状态。

$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                PORTS                                      NAMES
cdcf0acae1af        nginx:latest        "nginx -g 'daemon of…"   6 months ago        Removal In Progress                                              webproxy
c58e2a73f117        hexoblogs:latest    "nginx -g 'daemon of…"   11 months ago       Removal In Progress                                              dhblogs

删除时提示信息如下:

$ sudo docker rm webproxy
Error response from daemon: driver "devicemapper" failed to remove root filesystem for cdcf0acae1afb7da7e57653945b7322e32bc6909444558ba6834612b8bfa5ebd: remove /mnt/docker/devicemapper/mnt/5faf8f2ec431bad0e1e2938330b2844209e864b1b76c857fea5f29b44a18999a: device or resource busy

网上有很多类似的解决办法,但试了几个均不能使用,例如:

$ docker system prune
$ find /var/lib/docker -name "*webproxy*"
$ mount -l
$ umount
$ ...

最终解决方案:

$ grep docker /proc/*/mountinfo | grep 5faf8f2ec431bad0e1e2938330b2844209e864b1b76c857fea5f29b44a18999a
/proc/24762/mountinfo:145 143 252:5 / /mnt/docker/devicemapper/mnt/5faf8f2ec431bad0e1e2938330b2844209e864b1b76c857fea5f29b44a18999a rw,relatime shared:97 - xfs /dev/mapper/docker-253:17-15728997-5faf8f2ec431bad0e1e2938330b2844209e864b1b76c857fea5f29b44a18999a rw,nouuid,attr2,inode64,logbsize=64k,sunit=128,swidth=128,noquota
$ kill -9 24762
$ docker rm dhblogs
dhblogs

说明:grep检索的不是容器号,而是删除时提示信息中/mnt/docker/devicemapper/mnt/*** 驱动器号,得到占用该驱动器的进程号 24762(/proc/24762/mountinfo),杀死进程即可

你可能感兴趣的:(「 Docker」容器Removal In Progress删除方案)