以下の記事で紹介した、Dockerのマルチアーキテクチャ対応のimageをbuildしていたところ、apt-get updateの部分でdebianのGPGエラーが起きた。

https://note.yu9824.com/howto/2022/01/15/docker-multi-arch-build/

調べてみると、GPGエラーはセキュリティ的な意味合いだったので、元のイメージが原因だと思った。

しかし、別の場所に原因があったのでこのときの対処法と併せて示す。


表示されたエラーメッセージ

[linux/arm64  2/14] RUN apt-get update && apt-get install -y vim:
#21 0.109 Get:1 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
#21 0.158 Err:1 http://security.debian.org/debian-security bullseye-security InRelease
#21 0.158   At least one invalid signature was encountered.
#21 0.238 Get:2 http://deb.debian.org/debian bullseye InRelease [116 kB]
#21 0.277 Get:3 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
#21 0.305 Err:2 http://deb.debian.org/debian bullseye InRelease
#21 0.305   At least one invalid signature was encountered.
#21 0.335 Err:3 http://deb.debian.org/debian bullseye-updates InRelease
#21 0.335   At least one invalid signature was encountered.
#21 0.340 Reading package lists...
#21 0.349 W: GPG error: http://security.debian.org/debian-security bullseye-security InRelease: At least one invalid signature was encountered.
#21 0.349 E: The repository 'http://security.debian.org/debian-security bullseye-security InRelease' is not signed.
#21 0.349 W: GPG error: http://deb.debian.org/debian bullseye InRelease: At least one invalid signature was encountered.
#21 0.349 E: The repository 'http://deb.debian.org/debian bullseye InRelease' is not signed.
#21 0.349 W: GPG error: http://deb.debian.org/debian bullseye-updates InRelease: At least one invalid signature was encountered.
#21 0.349 E: The repository 'http://deb.debian.org/debian bullseye-updates InRelease' is not signed.
------
Dockerfile:5
--------------------
   3 |
   4 |     # Install vim to use git and modify commit message by using it.
   5 | >>> RUN apt-get update && apt-get install -y vim
   6 |
   7 |     # Set timezone
--------------------
error: failed to solve: process "/bin/sh -c apt-get update && apt-get install -y vim" did not complete successfully: exit code: 100

GPG errorとなっており、apt-get updateを失敗した。

原因

自分の場合もこちらの記事と同様にdisk容量がいっぱいだったために起きていた。

ディスク容量は「Preferences」>「Resources」>「Disk image size」から確認できる(写真は削除後のもの)。

/images/posts/2022-03-19-docker-desktop-preferences.png

/images/posts/2022-03-19-docker-desktop-preferences-diskimagesize.png

Disk image sizeを増やしてもよかったのだが、それでは本質的な改善にはならないと思ったので、先ほどの記事にあるようなキャッシュを削除する、以下に示したコマンドを実行した。

docker image prune

および

docker container prune

しかし、disk容量がいっぱいのまま改善しなかった。

既存の方法では改善しなかったのでやったこと

他にキャッシュを削除するコマンドを調べた。以下が公式のサイト。

これを参考に、

docker system prune

を実行したが、これでも改善せず困った。

最終的に解決した方法

そこで、GUIですべてのキャッシュを削除した。

「Troubleshoot(虫のマーク)」>「Reset to factory defaults」

/images/posts/2022-03-19-docker-desktop-troubleshoots.png

これによりディスク容量が改善した。

ディスク容量の減少を確認したのち再度ビルドしたところ、成功した。

コメント

コマンドで削除できなかったものの心当たりとしては、volumeのキャッシュかなと思うけれど、60 GBがすべてそれだったのかなと思うと疑問が残る。

docker system prune コマンドは、イメージ、コンテナ、ネットワークを削除(prune)するショートカットです。 Docker 17.06.0 以下のバージョンでは、ボリュームも prune されました。Docker 17.06.1 以降では、 docker system prune でボリュームも削除するには --volumes フラグが必要になりました。

使用していない Docker オブジェクトの削除(prune)

一応、次出会ったときは

docker system prune --volumes

を試してみようと思う。

追記 (2024/4/3)

this worked for me docker system prune -af --volumes and these other ones as well

docker image prune
docker container prune
docker builder prune
docker volume prune

This running docker system df and see if you need free space on one of your volumes

Repository is not signed in docker build - stackoverflow.com

関連

https://note.yu9824.com/howto/2021/09/04/docker-conda-activate/

https://note.yu9824.com/howto/2022/01/15/docker-multi-arch-build/

https://note.yu9824.com/howto/2022/03/12/docker-jupyter-setup/