APT Error: Type '<!doctype' on line 1 in nvidia-container-toolkit.list

Googled777 avatar   
Googled777
This tutorial explains how to fix a common APT error that occurs when the NVIDIA Container Toolkit repository is misconfigured and APT tries to read an HTML page as a package source.


Fix: APT Error with nvidia-container-toolkit.list and HTML Output

APT Error: Type '<!doctype' on line 1 in nvidia-container-toolkit.list

This tutorial explains how to fix a common APT error that occurs when the NVIDIA Container Toolkit repository is misconfigured and APT tries to read an HTML page as a package source.

1. Symptom: APT Error Message

When running sudo apt update, you may see:

E: Type '<!doctype' on line 1 in source list /etc/apt/sources.list.d/nvidia-container-toolkit.list is unknown
E: The list of sources could not be read.

This means APT found an HTML document inside a .list file instead of a valid deb repository entry.

Key point: The file /etc/apt/sources.list.d/nvidia-container-toolkit.list contains a web page (often a 404 page), not a repository.

2. Cause: Incorrect NVIDIA Repository URL

The issue usually appears when adding the NVIDIA repository like this:

distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/libnvidia-container/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list \
  | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

For some distributions (e.g., newer Ubuntu versions or derivatives), the $distribution directory does not exist in NVIDIA’s repository. Instead of a .list file, NVIDIA returns an HTML 404 page, which gets written directly into the .list file.

Result: As long as this corrupted file exists, apt update will continue to fail.

3. Step 1 – Inspect the .list File

Check what’s inside the file:

cat /etc/apt/sources.list.d/nvidia-container-toolkit.list

If you see something like:

<!doctype html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <title>Unsupported distribution or misconfigured repository settings</title>
    ...

then the file is definitely not a valid APT repository.

4. Step 2 – Remove the Corrupted File

Delete the invalid .list file:

sudo rm /etc/apt/sources.list.d/nvidia-container-toolkit.list

This removes the APT blockage, but the NVIDIA repository still needs to be added correctly.

5. Step 3 – Use NVIDIA’s Generic .deb Repository

Instead of a distribution-specific URL, use the generic .deb repository provided by NVIDIA. This works on most Debian/Ubuntu-based systems.

5.1 Install the GPG Key Properly

curl -s -L https://nvidia.github.io/libnvidia-container/gpgkey \
  | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit.gpg

5.2 Add the Repository with signed-by

curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list \
  | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit.gpg] https://#' \
  | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

6. Step 4 – Update APT

sudo apt update

The previous <!doctype> error should now be gone.

You can now install the NVIDIA Container Toolkit if needed:

sudo apt install -y nvidia-container-toolkit

7. Summary

  • Problem: APT reads an HTML 404 page as a repository file.
  • Cause: NVIDIA’s distro-specific URL does not exist for your system.
  • Fix:
    • Remove the corrupted .list file.
    • Install the GPG key via gpg --dearmor.
    • Use the generic stable/deb repository.
    • Run sudo apt update.
Whenever you see <!doctype html> inside an APT source file, it means you downloaded a web page instead of a repository.

This tutorial is based on a real-world debugging session involving a modern Ubuntu-based environment and NVIDIA Container Toolkit integration.

0 Comments

No comments found