[Fixed] Build started failing using Python:3.8 Docker image on apt-get update and install with GPG error: bookworm InRelease is not signed – Docker

by
Maya Patel
boot2docker debian debian-bookworm dockerfile python-3.x

Quick Fix: In the Dockerfile, add these lines:

RUN mv -i /etc/apt/trusted.gpg.d/debian-archive-*.asc  /root/
RUN ln -s /usr/share/keyrings/debian-archive-* /etc/apt/trusted.gpg.d/

This will copy the necessary GPG keys from /usr/share/keyrings to /etc/apt/trusted.gpg.d, allowing apt-get to verify the authenticity of packages from Debian’s bookworm repository.

The Problem:

A Docker build pipeline using a Python:3.8 image is failing with a GPG error related to an unsigned repository in Debian’s ‘bookworm’ release. The ‘apt-get update & apt-get install’ step in the Dockerfile is causing the failure due to missing public keys for signature verification. The goal is to identify the root cause of this issue and determine a solution to resolve the build failure.

The Solutions:

Solution 1: Fix by replacing `GPG` Keys

Reason:

  • Docker images for Python recently switched from Debian 10 buster version to Debian 12 bookworm.
  • The bookworm version needs a different GPG key for package verification compared to buster.

Fix:

  • Replace the old GPG keys with the new ones using the following commands in your Dockerfile:
RUN mv -i /etc/apt/trusted.gpg.d/debian-archive-*.asc /root/
RUN ln -s /usr/share/keyrings/debian-archive-* /etc/apt/trusted.gpg.d/
  • These commands will move the old GPG keys to a safe location and create symbolic links to the new keys.

  • After making this change, your apt-get update and apt-get install commands should work correctly on the Debian 12 bookworm version.

Solution 2: Update Docker System

The issue seems to be caused by an outdated Docker system. Updating the Docker system is the recommended and effective solution. Here’s how to do it:

  1. Ensure that you are using the latest version of Docker Desktop. You can check for updates by clicking on the Docker menu in the menu bar and selecting "Check for Updates." If there is an update available, follow the prompts to install it.

  2. If you are using Docker CLI, you can update Docker by running the following command:

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli
  1. Once the Docker system is updated, try rebuilding your image. The apt-get update and apt-get install commands in your Dockerfile should now work without errors.

Note: If you are unable to update the Docker system, you may need to contact your system administrator or hosting provider for assistance.

Q&A

Why is my build pipeline failing on apt-get update and install?

Python Docker images have been updated to Debian 12 bookworm.

What is causing the GPG error?

Missing public keys for Debian 12 bookworm InRelease.

How can I fix this issue?

Add trusted.gpg.d/debian-archive-* to /etc/apt.

Video Explanation:

The following video, titled "Related Video", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

This video provides further insights and detailed explanations related to the content discussed in the article.