Resolving GPG Error for Docker Repository on Ubuntu: A Step-by-Step Guide

Ashish Dwivedi
2 min readJul 5, 2023

Introduction: Managing software repositories is an integral part of maintaining a secure and up-to-date system. However, encountering errors during the repository update process can be frustrating. One common issue that Ubuntu users may face is the GPG error when attempting to update the Docker repository. In this article, we will explore the error message and provide a step-by-step solution to resolve it.

Section 1: Understanding the GPG Error When updating the Docker repository on Ubuntu, you might encounter the following error: “W: GPG error: https://download.docker.com/linux/ubuntu xenial InRelease: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 7EA0G9CBF1373FED8 W: The repository ‘https://download.docker.com/linux/ubuntu xenial InRelease’ is not signed. N: Data from such a repository can’t be authenticated and is therefore potentially dangerous to use. N: See apt-secure(8) manpage for repository creation and user configuration details.”

This error occurs when the system cannot verify the authenticity and integrity of the packages from the Docker repository due to a missing GPG key.

Section 2: Resolving the GPG Error To resolve the GPG error for the Docker repository on Ubuntu, follow these steps:

  1. Obtaining the Key ID: Start by noting the key ID mentioned in the error message. In our case, the key ID is “7E0000A9C3F37311D8”(Replace with your key ID).
  2. Importing the GPG Key: Open a terminal and run the following command to import the Docker GPG key:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 7EA0A9C3F273FCD8

3. Manually Adding the Docker Repository: Next, download the Docker GPG key and add the repository information manually. Execute the following commands:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

4. Updating Package Lists: Finally, update the package lists to reflect the changes made:

sudo apt update

Conclusion: By following the steps outlined in this article, you can overcome the GPG error that occurs when updating the Docker repository on Ubuntu. Importing the GPG key and manually adding the repository information ensures the authenticity and integrity of the packages obtained from the Docker repository.

Resolving this error enables you to stay up to date with the latest Docker releases and leverage the power of containerization in your development and deployment workflows.

Remember, maintaining secure and trusted software sources is crucial for a smooth and reliable computing experience.

Happy containerizing!

--

--