docker 删除容器,遇到:
devicemapper: Error running DeleteDevice dm_task_run failed
异常
[hadoop@hadoop02 ~]$ sudo docker rm 5ede1280f0bf
Error response from daemon: container 5ede1280f0bf791e91d40038b15decd42e8923546ae578abd96e08114c766478: driver "devicemapper" failed to remove root filesystem: failed to remove device 66e7e0583f028c2d6e7df3ef39e6a325e7dd7a2eadd06771373d7e94702d44c6: devicemapper: Error running DeleteDevice dm_task_run failed
journalctl -xe
...
Nov 25 21:46:35 hadoop02 sudo[18953]: hadoop : TTY=pts/1 ; PWD=/home/hadoop ; USER=root ; COMMAND=/bin/docker rm 5ede1280f0bf
Nov 25 21:46:36 hadoop02 kernel: device-mapper: thin: 253:10: unable to service pool target messages in READ_ONLY or FAIL mode
Nov 25 21:46:36 hadoop02 kernel: device-mapper: thin: 253:10: unable to service pool target messages in READ_ONLY or FAIL mode
Nov 25 21:46:36 hadoop02 dockerd[2072]: time="2023-11-25T21:46:36.308757603+08:00" level=error msg="Error removing mounted layer 5ede1280f0bf791e91d40038b15decd42e8923546ae578abd96e08114c766478: failed to remove device 66e7e0583f028c2d6e7df3ef39e6a325e7dd7a2eadd06771373d7e94702d44c6: devicemapper: Error running DeleteDevice dm_task_run failed"
Nov 25 21:46:36 hadoop02 dockerd[2072]: time="2023-11-25T21:46:36.309214859+08:00" level=error msg="Handler for DELETE /v1.41/containers/5ede1280f0bf returned error: container 5ede1280f0bf791e91d40038b15decd42e8923546ae578abd96e08114c766478: driver \"devicemapper\" failed to remove device 66e7e0583f028c2d6e7df3ef39e6a325e7dd7a2eadd06771373d7e94702d44c6: devicemapper: Error running DeleteDevice dm_task_run failed"
Nov 25 21:46:36 hadoop02 systemd-udevd[18960]: inotify_add_watch(7, /dev/dm-11, 10) failed: No such file or directory
解决方法:
1、systemctl stop docker
2、thin_check /var/lib/docker/devicemapper/devicemapper/metadata
3、thin_check --clear-needs-check-flag /var/lib/docker/devicemapper/devicemapper/metadata
4、systemctl start docker
参考:https://stackoverflow.com/questions/30719896