LoginSignup
2
2

More than 5 years have passed since last update.

EC2上の容量がいっぱいになったので、きれいにする

Last updated at Posted at 2018-12-05

概要

開発を行っていて、EC2の空き容量がなくなって、以下のようなメッセージが出てきた。

E: Failed to fetch http://deb.debian.org/debian/dists/stretch/main/binary-amd64/Packages  Error writing to output file - write (28: No space left on device) Error writing to file - write (28: No space left on device)
E: Some index files failed to download. They have been ignored, or old ones used instead.

そのため、容量を開けるための方法を以下にメモする。
と、その前に、本当に容量がいっぱいかを確認するためには以下のコマンドを実行する。

df -h

私のインスタンスは想定通り満杯だ。

Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1      8.0G  8.0G   48M 100% /

方法

Dockerのごみを削除

とりあえず、たまりにたまっているであろうDockerのごみを削除。以下のコマンドを実行。

docker system prune -a

結果は以下。1.5GB空いた。

Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1      8.0G  6.6G  1.5G  83% /

docker system prune -aは、全ての停止中のコンテナ、ボリューム、ネットワーク、イメージを一括削除するコマンドみたいだが(参考)、以下のコマンドでvolumeも削除したところ、もっと空いた。

docker volume prune

結果はVolumeの削除だけで2.7GB空いた。合計で4GB以上、50%以上空いた。

参考

2
2
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
2
2