[Docker] docker build 時遇到 no space left on device 錯誤

[Docker] docker build 時遇到 no space left on device 錯誤

今天在 Mac 上跑  docker build 的時候,

突然出現了 no space left on device 的錯誤訊息:

Step 3/10 : RUN apk update && apk upgrade zlib=1.2.12-r2
 ---> Using cache
 ---> a18f7cf6c2d9
Step 4/10 : ADD build/patrol /patrol
write /patrol: no space left on device

 

用  df -h 看一下硬碟空間,還剩 275 GB,

看起來並不是硬碟滿了:

$ df -h

Filesystem       Size   Used  Avail Capacity iused      ifree %iused  Mounted on
/dev/disk1s1s1  932Gi  8.5Gi  275Gi     4%  356049 2879588160    0%   /
devfs           362Ki  362Ki    0Bi   100%    1252          0  100%   /dev
/dev/disk1s3    932Gi  1.9Gi  275Gi     1%    3702 2879588160    0%   /System/Volumes/Preboot
/dev/disk1s5    932Gi  9.0Gi  275Gi     4%       9 2879588160    0%   /System/Volumes/VM
/dev/disk1s6    932Gi   17Mi  275Gi     1%      20 2879588160    0%   /System/Volumes/Update
/dev/disk1s2    932Gi  636Gi  275Gi    70% 4808385 2879588160    0%   /System/Volumes/Data
map auto_home     0Bi    0Bi    0Bi   100%       0          0  100%   /System/Volumes/Data/home

 

想起來這可能是 docker 儲放映像檔和容器的固定目錄滿了…

沒來的及查看,直接跑了  docker system prune 來清除垃圾,

這會把所有停止的容器、非使用中的映像檔、和所有的 build 快取都清掉:

$ docker system prune --all

WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all images without at least one container associated to them
  - all build cache

Are you sure you want to continue? [y/N] y

Deleted Containers:
dfa5f9715dbb82baf5abeb1029de53481269ee1b8044c739c267732279e3c865
c5255b811a7d7363da23d3b2f82fa86e159ffc881dc1c2e63aa3584fad3ecd8a
......
Deleted Images:
deleted: sha256:e276af41f3da6af400dcb2182c308f4348b4957026b92079fe9a25eec87f9172
deleted: sha256:33547b3fed43955fcba2392a1d14e0820226f779de488f657fd8895f6df1fabd
......
Deleted build cache objects:
qqam0jhipnmayw3ggm25nkzrg
l3auar4lfejwu5x11xl1a3qn3
......
Total reclaimed space: 87.88GB

 

一口氣清掉了將近 88 GB 的空間出來,出乎我的意料…

清完之後,no space left on device 的錯誤訊息就不再出現囉~

 

參考資料:Docker no space left on device

(本頁面已被瀏覽過 85 次)

One thought on “[Docker] docker build 時遇到 no space left on device 錯誤

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料