This error occurs when apt cannot find a linux-image package matching your current kernel version. It commonly happens after a fresh Ubuntu installation, inside containers, or on systems with custom kernels. The fix requires updating your package cache and verifying the correct package exists for your kernel variant.
When you run a command like `sudo apt-get install -y linux-image-extra-$(uname -r)`, apt expands `$(uname -r)` to your current kernel version (e.g., `5.15.0-47-generic`), then searches for `linux-image-extra-5.15.0-47-generic` in the configured repositories. The error means that specific package doesn't exist in any enabled repository, or the repository metadata is outdated. This typically indicates a mismatch between your running kernel and available packages in the repository, or that you're running a custom/specialized kernel for which kernel-extra packages were never published.
Start by refreshing the apt package lists. This is essential because the error might be due to stale repository metadata:
sudo apt-get updateThen retry your original installation:
sudo apt-get install -y linux-image-$(uname -r)If the error persists, proceed to the next step. The package cache update resolves about 40% of these errors, especially on freshly installed systems or inside containers.
Check what kernel you're running and whether linux-image packages exist for it:
# See your current kernel version
uname -r
# Search for available linux-image packages matching your kernel
apt-cache search linux-image | grep $(uname -r)
# For linux-image-extra specifically
apt-cache search linux-image-extra | grep $(uname -r)If no results appear, your kernel variant doesn't have published packages. Proceed to step 3.
If results appear but the exact package is missing (e.g., you see linux-image-5.15.0-47 but need linux-image-extra-5.15.0-47-generic), your repository might be incomplete or you're on a specialized system.
Modern Ubuntu systems often use linux-modules-extra instead of linux-image-extra. Try this alternative:
sudo apt-get install -y linux-modules-extra-$(uname -r)This package provides the kernel modules that linux-image-extra previously provided and is the recommended approach for newer Ubuntu versions. It has better compatibility and is actively maintained.
Some kernel packages live in the universe repository, which isn't enabled by default. Enable it and try again:
# Enable universe repository
sudo add-apt-repository universe
# Update package lists
sudo apt-get update
# Try installing again
sudo apt-get install -y linux-image-extra-$(uname -r)Verify the repository is enabled by checking:
grep "^deb.*universe" /etc/apt/sources.list /etc/apt/sources.list.d/*If you're installing Docker and the error persists, the linux-image-extra package is often not strictly required on modern systems. Docker documentation states that on newer Ubuntu versions, these packages are optional.
If you need to proceed without it:
# Continue with Docker installation without linux-image-extra
# (Skip the line that installs linux-image-extra)
# Or manually install just what you need
sudo apt-get install -y docker.ioOnly skip this if you're certain the extra modules aren't needed for your specific use case.
For specialized kernel environments (AWS, Proxmox, KVM, WSL): These platforms often use custom kernel builds that don't have corresponding linux-image-extra packages in Ubuntu repositories. In these cases, the packages simply aren't available and cannot be installed. Instead, use linux-modules-extra if available, or install the package from source if absolutely necessary.
For Docker specifically: Modern Docker versions (20.10+) support running without the linux-image-extra package on most systems. The package was critical for older Docker versions to enable the AUFS storage driver, but newer versions use overlay2 by default, which doesn't require these extra packages.
For container and WSL environments: When building Docker containers or running in Windows Subsystem for Linux, the expanded kernel version might not match any published packages because you're using the host's kernel. The best practice is to skip installing kernel packages inside containers and rely on the host system to have necessary kernel modules.
E: Could not connect to proxy server
Could not connect to proxy server
E: Package 'package:i386' has no installation candidate
How to fix "Package package:i386 has no installation candidate" in apt
E: The value 'value' is invalid for APT::Default-Release
How to fix invalid APT::Default-Release value in APT
dpkg: error: unable to create new file 'path': Permission denied
How to fix dpkg permission denied errors in APT
subprocess installed post-removal script returned error exit status 1
How to fix "subprocess installed post-removal script returned error exit status 1" in APT