iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🐳

Solving Docker Repository '404 Not Found' Error on elementary OS when using apt

に公開

I encountered an issue while trying to use Docker on elementary OS, so I am recording the solution here.

Who this is for

  • Users who tried to add Docker via apt on elementary OS but received errors such as 404 Not Found.

Environment

elementary OS 5.1.7 Hera

How the error occurred

While trying to use Docker in an elementary OS (Release: 5.1.7) environment, I attempted to add the repository according to the tutorial.

Then, when I ran sudo apt update:

$ sudo apt update
Hit:1 http://jp.archive.ubuntu.com/ubuntu bionic InRelease                                           
Hit:2 http://jp.archive.ubuntu.com/ubuntu bionic-updates InRelease                                   
Hit:3 http://dl.google.com/linux/chrome/deb stable InRelease                                         
Hit:4 http://jp.archive.ubuntu.com/ubuntu bionic-backports InRelease                                 
Hit:5 http://packages.elementary.io/appcenter bionic InRelease                                       
Hit:6 http://ppa.launchpad.net/elementary-os/stable/ubuntu bionic InRelease                          
Hit:7 http://repository.spotify.com stable InRelease                                                 
Hit:8 https://typora.io/linux ./ InRelease                                                           
Hit:9 https://brave-browser-apt-release.s3.brave.com stable InRelease                                
Hit:10 http://security.ubuntu.com/ubuntu bionic-security InRelease                                   
Hit:11 http://packages.microsoft.com/repos/code stable InRelease                                     
Hit:13 http://ppa.launchpad.net/elementary-os/os-patches/ubuntu bionic InRelease                     
Ignore:14 https://download.docker.com/linux/ubuntu hera InRelease                                         
Hit:15 https://packages.microsoft.com/repos/ms-teams stable InRelease                                
Error:16 https://download.docker.com/linux/ubuntu hera Release                                         
  404  Not Found [IP: 2600:9000:20e4:f600:3:db06:4200:93a1 443]
Hit:12 https://packagecloud.io/slacktechnologies/slack/debian jessie InRelease                       
Reading package lists... Done
E: The repository 'https://download.docker.com/linux/ubuntu hera Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Both Ignore and Error logs appeared. (Relevant parts below:)

Ignore:14 https://download.docker.com/linux/ubuntu hera InRelease           
  ...
Error:16 https://download.docker.com/linux/ubuntu hera Release                                         
  404  Not Found [IP: 2600:9000:20e4:f600:3:db06:4200:93a1 443]
  ...
E: The repository 'https://download.docker.com/linux/ubuntu hera Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Solution

The cause was that I was running commands intended for Ubuntu directly on elementary OS. Below is the solution.

Run the following command:

$ cat /etc/os-release

Check the output:

NAME="elementary OS"
VERSION="5.1.7 Hera"
ID=elementary
ID_LIKE=ubuntu
PRETTY_NAME="elementary OS 5.1.7 Hera"
LOGO=distributor-logo
VERSION_ID="5.1.7"
HOME_URL="https://elementary.io/"
SUPPORT_URL="https://elementary.io/support"
BUG_REPORT_URL="https://github.com/elementary/os/issues/new"
PRIVACY_POLICY_URL="https://elementary.io/privacy-policy"
VERSION_CODENAME=hera
UBUNTU_CODENAME=bionic

Remember the last UBUNTU_CODENAME. In this case, the codename is bionic.

Remove the repository you already added (command for 64-bit PC):

$ sudo add-apt-repository -r "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

Register the Docker repository for the codename (bionic) you just found:

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   bionic \
   stable"

Try running sudo apt update:

$ sudo apt update
Hit:1 http://jp.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://jp.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]                           
Get:3 http://jp.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]                         
Hit:4 http://ppa.launchpad.net/elementary-os/stable/ubuntu bionic InRelease                          
Hit:5 http://packages.microsoft.com/repos/code stable InRelease                                      
Hit:6 http://dl.google.com/linux/chrome/deb stable InRelease                                         
Hit:7 https://brave-browser-apt-release.s3.brave.com stable InRelease                                
Hit:8 https://download.docker.com/linux/ubuntu bionic InRelease                                      
Hit:9 http://packages.elementary.io/appcenter bionic InRelease                                       
Hit:10 https://typora.io/linux ./ InRelease                                                          
Hit:11 https://packages.microsoft.com/repos/ms-teams stable InRelease                                
Hit:12 http://repository.spotify.com stable InRelease                                                
Hit:13 http://ppa.launchpad.net/elementary-os/os-patches/ubuntu bionic InRelease                     
Hit:14 http://security.ubuntu.com/ubuntu bionic-security InRelease                                   
Hit:15 https://packagecloud.io/slacktechnologies/slack/debian jessie InRelease                       
Fetched 163 kB in 3s (50.1 kB/s)
Reading package lists... Done
Building dependency tree       
Reading state information... Done

It's fixed.

Cause

I spent quite some time trying to figure this out, but after investigating and understanding everything, I re-read the documentation and found that a note was clearly stated.

Note: The lsb_release -cs sub-command below returns the name of your Ubuntu distribution, such as xenial. Sometimes, in a distribution like Linux Mint, you might need to change $(lsb_release -cs) to your parent Ubuntu distribution. For example, if you are using Linux Mint Tessa, you could use bionic. Docker does not offer any guarantees on untested and unsupported Ubuntu distributions.

Briefly, it says:
"The lsb_release -cs sub-command returns the name of your Ubuntu distribution. If you are using something like Linux Mint, change the $(lsb_release -cs) part to the parent Ubuntu distribution it is based on."

For those using Ubuntu-based distributions like elementary OS or Mint, running $(lsb_release -cs) returns the name of your specific distribution instead of the base Ubuntu codename.

$ lsb_release -a
No LSB modules are available.
Distributor ID:	elementary
Description:	elementary OS 5.1.7 Hera
Release:	5.1.7
Codename:	hera

$ lsb_release -cs
hera

If you run the following command without considering this:

 echo \
  "deb [arch=arm64 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

The system tries to find a repository for the Ubuntu codename Hera. Since that doesn't exist, it results in a 404 Error.

By running $ cat /etc/os-release to find the base Ubuntu distribution name and replacing the $(lsb_release -cs) part with it, you can register a Docker repository that both exists and is compatible with your OS.

Discussion