[Docker] 刪除容器時,出現 Error running DeleteDevice dm_task_run failed 錯誤
今天想要移除一個 docker container 時,
突然遇到奇怪的錯誤,說 devicemapper: Error running DeleteDevice dm_task_run failed:
testuser@localhost ~ $ docker rm -f a0a58ab923ba Error response from daemon: Driver devicemapper failed to remove root filesystem a0a58ab923bad5657eabbe5fa00d241471e233f1f142833cde5f4707e060de3d: failed to remove device 87a472753633c2b7b69321f116f7cfaaed4d3079c978646777162cf5d7c11fcd-init:devicemapper: Error running DeleteDevice dm_task_run failed
查了一下好像沒什麼好方法,
想想反正這些 container 都可以再重建,
那就先停掉 docker 服務,刪掉 /var/lib/docker 目錄,
再重啟 docker 服務:
systemctl stop docker sudo rm -rf /var/lib/docker systemctl start docker
docker 服務重啟後,/var/lib/docker 的目錄又自己長出來了:
testuser@localhost ~ $ sudo ls -l /var/lib/docker total 0 drwx------. 2 root root 6 Sep 9 11:23 containers drwx------. 3 root root 21 Sep 9 11:23 image drwxr-x---. 3 root root 18 Sep 9 11:23 network drwx------. 3 root root 38 Sep 9 11:23 overlay2 drwx------. 4 root root 30 Sep 9 11:23 plugins drwx------. 2 root root 6 Sep 9 11:23 swarm drwx------. 2 root root 6 Sep 9 11:23 tmp drwx------. 2 root root 6 Sep 9 11:23 trust drwx------. 2 root root 24 Sep 9 11:23 volumes
這時用 docker ps 或 docker images 指令,
會發現所有的 container 和映象檔,都已經消失了:
testuser@localhost ~ $ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES testuser@localhost ~ $ docker images -a REPOSITORY TAG IMAGE ID CREATED SIZE
參考資料:Docker dm_task_run failed error – Stack Overflow
(本頁面已被瀏覽過 1,181 次)