0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【AWS】EC2内のDockerでcomposer insatllしようとしたときに失敗した話

Last updated at Posted at 2022-03-08

はじめに

EC2内部でDockerが動作している環境で、composer install をしようとしたときに遭遇した問題のメモ

問題

-bash: cannot create temp file for here-document: No space left on device

上記が出た。調べてみると、

[ec2-user@hoge-web01 ~]$ df -h
/dev/nvme0n1p1  8.0G  8.0G   20K 100% /
127.0.0.1:/     8.0E   17M  8.0E   1% /hoge/storage

EC2にアタッチしているEBSが悲鳴を上げていた。

原因調査

何のファイルが悪さをしているのだろうとみてみると

[ec2-user@hoge-web01 ~]$ sudo du -k / | sort -n | tail -10
852348  /var/log/journal/hogehogehoge
1142784 /var/lib/docker/overlay2/hogehogehogehogehoge/merged
1701636 /var/lib/docker/overlay2/hogehogehogehogehoge

「docker/overlay2」と「journal」が悪さをしていた。
つまりログですね。

[ec2-user@hoge-web01 ~]$ sudo du -sh /var/lib/docker/overlay2/
5.2G    /var/lib/docker/overlay2/

アメイジング。

解決

まずjornalを対応しようということで

[ec2-user@hoge-web01 ~]$ journalctl --disk-usage
Archived and active journals take up 832.3M on disk.

数MBえいや。

[ec2-user@dev-taxinext-web01 ~]$ sudo journalctl --vacuum-size=100M

・・・

Deleted archived journal /var/log/journal/hogehoge.journal (8.0M).
Vacuuming done, freed 712.3M of archived journals on disk.

ちょっと消えている。

[ec2-user@dev-taxinext-web01 ~]$ journalctl --disk-usage
Archived and active journals take up 120.0M on disk.

dockerコンテナにログインして、composer install

root@hoge:/hoge/web# php -d memory_limit=-1 $(which composer) install

無事通ってくれました。

ちなみに

「docker/overlay2」も悪さしていたのですが、これは無駄なdockerコンテナが動作していることが原因でした。

docker buildやpullしたときに増えるみたいです。
以下の記事が鬼分かりやすいので、参考に。

余談

この時、実は、EBSそもそも小さいよねってことで、16GBにEBSを増加させています。(journal消した後に)

FAILED: failed: sfdisk --list /dev/nvme0n1

などと言われたりしていたので、
以下とかの記事を参考にさせていただきながら、解消しました。

https://aws.amazon.com/jp/premiumsupport/knowledge-center/ebs-volume-size-increase/
https://tech.innovator.jp.net/entry/expand-nvme-ebs
https://qiita.com/snaka/items/44dbe2cba8b63c3faa5a

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?