0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【備忘録】Dockerfile内の`apt-get update`がGPGエラーで失敗する

Posted at

概要

nginxのイメージをもとにDockerをビルドしていたのですが、どうあがいてもGPGエラーでapt-get updateができなくなってしまいました。

Building proxy
Step 1/12 : FROM nginx:1.25.3
 ---> d453dd892d93
Step 2/12 : RUN apt-get update -y
 ---> Running in 111d4ba94f4f
Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB]
Get:2 http://deb.debian.org/debian bookworm-updates InRelease [52.1 kB]
Get:3 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]
Err:1 http://deb.debian.org/debian bookworm InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY 6ED0E7B82643E131 NO_PUBKEY F8D2585B8783D481
Err:2 http://deb.debian.org/debian bookworm-updates InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY 6ED0E7B82643E131
Err:3 http://deb.debian.org/debian-security bookworm-security InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 54404762BBB6E853 NO_PUBKEY BDE6D2B9216EC7A8
Reading package lists...
W: GPG error: http://deb.debian.org/debian bookworm InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY 6ED0E7B82643E131 NO_PUBKEY F8D2585B8783D481
E: The repository 'http://deb.debian.org/debian bookworm InRelease' is not signed.
W: GPG error: http://deb.debian.org/debian bookworm-updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY 6ED0E7B82643E131
E: The repository 'http://deb.debian.org/debian bookworm-updates InRelease' is not signed.
W: GPG error: http://deb.debian.org/debian-security bookworm-security InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 54404762BBB6E853 NO_PUBKEY BDE6D2B9216EC7A8
E: The repository 'http://deb.debian.org/debian-security bookworm-security InRelease' is not signed.
E: Problem executing scripts APT::Update::Post-Invoke 'rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true'
E: Sub-process returned an error code
ERROR: Service 'proxy' failed to build : The command '/bin/sh -c apt-get update -y' returned a non-zero code: 100

解決方法

イメージの外側、ホストマシンでDocker自体の更新をしてみます。

apt upgrade docker

上記のコマンド終了時、どうやらエラーとなっているパッケージがある旨の表示が出力されました。

Errors were encountered while processing:
  nginx-core
  nginx-full
  nginx
  python3-certbot-nginx

ホストマシンにインストールされたパッケージとDockerイメージ内のパッケージが競合している(?)ということなのか・・・?

それらをアンインストールしてみます。

sudo apt remove nginx-core nginx nginx-full python3-certbot-nginx

結果、Dockerfileのビルドが通るようになりました。
Dockerは結構使っているつもりですが、やっぱりハマるときはハマるんですよねえ・・・(8時間近くハマった)

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?