Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

apt-get install in a Dockerfile fails with 404 Not Found from archive.ubuntu.com

ErrorE: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/... 404 Not Found

Short answer

A 404 means the package file listed in your apt index is no longer on the mirror. Inside Docker that is either a cached apt-get update layer that is older than the mirror, or a base image from an Ubuntu release that has reached end of life and was moved to the old-releases archive.

  • Applies to Docker Engine 28, Docker BuildKit, Ubuntu 22.04, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Read the Dockerfile's apt lines and the release the image is built on. The two causes differ in exactly those two things.

    grep -n -E "^FROM|apt-get" Dockerfile
    docker run --rm IMAGE_NAME cat /etc/os-release
  2. 2Match what you see, then jump to its fix

    1. 1The build used to work, 404 appears after an unrelated change, and the log shows CACHED next to the apt-get update stepapt-get update sits in its own, cached RUN layerFix
    2. 2os-release shows a non-LTS or very old release, and every package returns 404 even with a fresh updateThe base image is an Ubuntu release that has reached end of lifeFix

What does the error look like?

  • E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/... 404 Not Found
  • E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Cause 1 of 2

apt-get update sits in its own, cached RUN layer

1Check

When RUN apt-get update is a separate instruction, Docker reuses its cached layer, so the package index is old while the later install step asks for newer file names.

grep -n -B1 -A3 "apt-get update" Dockerfile

2Fix

Put update and install in the same RUN instruction, so a change to the package list also refreshes the index.

RUN apt-get update && apt-get install -y --no-install-recommends \
    curl \
    ca-certificates

3Verify

Rebuild; the 404 is gone because the index is fetched together with the install.

docker build --progress=plain -t my-image .

Confirmed by docs.docker.com

Did this fix it?

Cause 2 of 2

The base image is an Ubuntu release that has reached end of life

1Check

Compare the release with Ubuntu's list of releases. Ubuntu announces that an end-of-life release is archived to old-releases.ubuntu.com, so the normal mirrors stop serving it. Releases such as 25.04, which ended on 15 January 2026, are in this group.

docker run --rm IMAGE_NAME sh -c '. /etc/os-release; echo $VERSION_ID $VERSION_CODENAME'

2Fix

Move the image to a supported release, such as an LTS. Ubuntu's list shows 24.04 supported until 2029 and 22.04 until 2027.

FROM ubuntu:24.04

3Verify

Rebuild with no cache so every layer is fetched again.

docker build --no-cache --progress=plain -t my-image .

Confirmed by discourse.ubuntu.com

Did this fix it?

How do I stop it coming back?

  • Pin base images to an LTS tag, and review the pin when the release nears end of standard support.
  • Always write apt-get update and apt-get install in the same RUN.
  • Rebuild images on a schedule so the package index never gets far behind.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.