UGA Boxxx

つぶやきの延長のつもりで、知ったこと思ったこと書いてます

【Docker】急にspring-boot:build-imageでdockerイメージがつくれなくなったときの復旧メモ

Spring Bootのmvn spring-boot:build-imageをつかってdockerイメージをつくろうとしたところ、以下のエラーが発生した

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dockerPresenceMarker' defined in class path resource [com/playtika/test/common/spring/DockerPresenceBootstrapConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.playtika.test.common.spring.DockerPresenceMarker]: Factory method 'dockerPresenceMarker' threw exception; nested exception is com.playtika.test.common.spring.DockerNotPresentException: Docker must be present in order for testcontainers to work properly!          
...
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.playtika.test.common.spring.DockerPresenceMarker]: Factory method 'dockerPresenceMarker' threw exception; nested exception is com.playtika.test.common.spring.Docker
NotPresentException: Docker must be present in order for testcontainers to work properly!                                                                                                                                                                       
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)                                                                                                                              
        at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)                                                                                                                                              
        ... 107 more                                                                                                                                                                                                                                            
Caused by: com.playtika.test.common.spring.DockerNotPresentException: Docker must be present in order for testcontainers to work properly!

何度も使っているコマンドなので急にエラーになったことがわからず、だいぶ原因解明に時間がかかったが、ログを見直すと最初の方で

❌ Docker environment should have more than 2GB free disk space

となっているのをみつけた

つまり、Docker環境で確保しているdiskスペースが不足しているのが原因ぽい

docker for mac を使っていたので、こちらの記事が参考になった
Docker for Mac におけるディスク使用量 — Docker-docs-ja 20.10 ドキュメント

確かに、不要なイメージがたくさんあったので

以下のコマンドで一回綺麗にしてみた

$ docker system prune

ただ、こんどはdocker for macが起動しなくなってしまったため、インストールし直したらうまく起動し、イメージも作成することができた