执行删除命令无法删除docker的目录

[root@master shell]# rm -rf /var/lib/docker
rm: 无法删除"/var/lib/docker/overlay/50f73bfd98368e3d9f47aac7d23ae12b514ade1c283b88013995b12a5f238860/merged": 设备或资源忙

网络共享挂载导致无法删除,首先找到挂载的位置,然后取消挂载后,就可以删除。

[root@master shell]# cat /proc/mounts |grep "docker"
/dev/mapper/centos-root /var/lib/docker/overlay xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
overlay /var/lib/docker/overlay/50f73bfd98368e3d9f47aac7d23ae12b514ade1c283b88013995b12a5f238860/merged overlay rw,seclabel,relatime,lowerdir=/var/lib/docker/overlay/a764e1d503861296ffe63f9f3e20ccd440b12abbaceb5ba49ddac8640b1aad96/root,upperdir=/var/lib/docker/overlay/50f73bfd98368e3d9f47aac7d23ae12b514ade1c283b88013995b12a5f238860/upper,workdir=/var/lib/docker/overlay/50f73bfd98368e3d9f47aac7d23ae12b514ade1c283b88013995b12a5f238860/work 0 0

取消挂载

umount /var/lib/docker/overlay/50f73bfd98368e3d9f47aac7d23ae12b514ade1c283b88013995b12a5f238860/merged

再次查看

[root@master shell]# cat /proc/mounts |grep "docker"
/dev/mapper/centos-root /var/lib/docker/overlay xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0

取消挂载

[root@master shell]# umount /var/lib/docker/overlay

现在删除就能正常删除。

Logo

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

更多推荐