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?

Docker × Rails × Copilot デプロイで `lograge_development.log` エラー発生と解決メモ

Last updated at Posted at 2025-05-16

背景

Copilot + Docker + Rails 環境で ./copilot/deploy.sh dev2 を実行した際に、これまで動いていた環境で突然アセットプリコンパイルエラーが発生しました。

image.png


エラー内容

=> ERROR [9/9] RUN bin/rake assets:precompile

Rails Error: Unable to access log file.
Please ensure that /app/log/development.log exists and is writable.

Errno::ENOENT: No such file or directory @ rb_sysopen - /app/log/lograge_development.log

Dockerfile の以下のステップで失敗:

RUN bin/rake assets:precompile

調査

  • ソースコード自体には変更がなく、以前は動いていたため、環境依存の問題を疑いました
  • エラーメッセージを見ると、lograge_development.log ファイルがなくアクセスできないことが原因のようです

一時対応(失敗)

Dockerfile に以下の処理を追加して、ログファイルを作成・権限付与しようとしました。

# Ensure log directory and files exist and are writable
RUN mkdir -p log \
 && touch log/development.log log/lograge_development.log \
 && chmod -R 0664 log

しかし、以下のように別のエラーが発生:

mkdir: cannot create directory ‘log’: No space left on device


原因

ディスク容量不足(No space left on device) が原因でした。

Docker Desktop for Mac のディスク使用状況を確認すると、容量が上限に達していました。


解決策

解決策1

不要な Docker イメージとコンテナを削除してディスクを解放:

docker system prune -a
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
docker system df
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          3         3         929.8MB   0B (0%)
Containers      3         3         1.287kB   0B (0%)
Local Volumes   13        1         1.983GB   1.982GB (99%)
Build Cache     0         0         0B        0B

これにより容量が空き、再度デプロイすると正常に通りました。

解決策2

Dockerのdiskの制限容量を上げる

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?