1
0

More than 1 year has passed since last update.

no space left on device エラーが出てdocker-composeコマンドが使えない

Posted at

やりたいこと

docker-composeコマンドを使えるようにしたい

起きたエラー内容

% docker-compose up --build
Building app
[+] Building 0.1s (1/2)                                 
 => [internal] load build definition from Dockerf  0.0s
 => => transferring dockerfile: 37B                0.0s
failed to solve with frontend dockerfile.v0: failed to read dockerfile: failed to create temp dir: mkdir /var/lib/docker/tmp/buildkit-mount013611257: no space left on device
ERROR: Service 'app' failed to build : Build failed

原因

先ほどのエラーで「スペースがない」とのことなのでdocker system dfを見てみる。

% docker system df
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          37        5         27.27GB   24.44GB (89%)
Containers      9         0         1.151kB   1.151kB (100%)
Local Volumes   2         2         238.3MB   0B (0%)
Build Cache     215       0         21.3GB    21.3GB

コンテナが100%になっているのでまずはこれを削減していく。

解決法

①停止して24時間経過したコンテナと、使っていないイメージおよびネットワークを消す

% docker system prune -a --filter "until=24h"
% docker system df
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          6         2         5.978GB   4.374GB (73%)
Containers      6         0         0B        0B
Local Volumes   2         1         238.3MB   207MB (86%)
Build Cache     46        0         1.919GB   1.919GB

とりあえずコンテナの値が0になった。

②ボリュームを消す
未使用のローカルボリュームを削除します。 未使用のローカルボリュームとは、どのコンテナーからも参照されていないボリュームのことです。

% docker volume prune
WARNING! This will remove all local volumes not used by at least one container.
Are you sure you want to continue? [y/N] y
Deleted Volumes:
movie-review2_mysql-data

Total reclaimed space: 207MB
% docker system df   
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          6         2         5.978GB   4.374GB (73%)
Containers      6         0         0B        0B
Local Volumes   1         1         31.38MB   0B (0%)
Build Cache     46        0         1.919GB   1.919GB

ボリュームもサイズが一気にコンパクトになりました。

③イメージの削除

% docker images
REPOSITORY         TAG       IMAGE ID       CREATED        SIZE
movie-reivew_app   latest    f6f2f817bfc2   8 hours ago    1.97GB
<none>             <none>    5b6d6c73dfa2   9 hours ago    1.97GB
<none>             <none>    9413feea8f5a   10 hours ago   1.97GB
<none>             <none>    1146e2c6ed52   10 hours ago   1.97GB
<none>             <none>    7d77e82b4a70   10 hours ago   1.97GB
<none>             <none>    7b5e96b58c6d   10 hours ago   1.97GB
% docker image prune
WARNING! This will remove all dangling images.
Are you sure you want to continue? [y/N] y
Deleted Images:
deleted: sha256:9413feea8f5a44bbaa65c5bc2f696ccfa6e3b79daed4427fcc592e4d5d6c3fd5
deleted: sha256:1146e2c6ed52fd0863b32b9ec1c46a6c7f2966b2cb8236c4832e90c801d15d87
deleted: sha256:7b5e96b58c6d3d9731dec3effc197b71722f0eac64fa73b161d54e3e1ee9f41a
deleted: sha256:7d77e82b4a70aa3d3be0b222bb6b9d9d8ffc4f579eb60afb48153471b2a9d103

Total reclaimed space: 0B

docker image pruneで宙ぶらりんになっているイメージを削除します。

% docker system df  
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          2         2         2.77GB    1.166GB (42%)
Containers      6         0         0B        0B
Local Volumes   1         1         31.38MB   0B (0%)
Build Cache     46        0         5.127GB   5.127GB

無事docker-compose up --buildができました!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0