apt-get install in a Dockerfile fails with 404 Not Found from archive.ubuntu.com
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/... 404 Not FoundShort 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.
Fix it fast
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-release2Match what you see, then jump to its fix
- 1
The 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
os-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
- 1
What does the error look like?
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/... 404 Not FoundE: 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" Dockerfile2Fix
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-certificates3Verify
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
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.043Verify
Rebuild with no cache so every layer is fetched again.
docker build --no-cache --progress=plain -t my-image .Confirmed by discourse.ubuntu.com
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
Servers
apt-get returns 404 Not Found while building an old Debian-based image
E: Failed to fetch ... dists/jessie ... 404 Not Found
Debian Jessie reached end of life in 2018 and its packages now live only on archive.debian.org.
3 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
sam local fails: Running AWS SAM projects locally requires Docker
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
sam local start-api and sam local invoke run your function inside a Docker container, so SAM stops if it cannot talk to Docker.
3 causes, each with a fixServers
dnf fails to download repo metadata in a CentOS 8 Docker build
The same Dockerfile built fine before 2022
CentOS Linux 8 reached end of life on 31 December 2021 and its content left the mirrors.
2 causes, each with a fixServers
pip install confluent-kafka fails because librdkafka/rdkafka.h is missing
pip stops while building confluent-kafka from source
The error means pip is compiling confluent-kafka from source, and the compiler cannot find the librdkafka C headers.
3 causes, each with a fixServers
Cypress says the npm package is installed but the binary is missing
Cypress binary is missing after npm install in CI or in a Docker build
The npm package is only a launcher.
3 causes, each with a fix