I am trying to create a Docker container based on Ubuntu 22.04. When I apt-get install
packages, I get a weird error: several dozen, sometimes a few hundred, packages succeed without issue, then one individual package will fail with a 403 forbidden
error.
This issue is intermittent. When one package fails, it will consistently continue to fail when I retry the Docker build. But once I clear the Docker build cache, or try again the next day, a different package will be the problem.
Occasionally, there are no problems, and the entire build succeeds.
Causes I have ruled out:
- Bad repository: the problematic package is always from the same Apt repository as all of the other packages which just succeeded seconds earlier
- Firewall issue: when I
curl
the URL that gave the 403 error, either outside of the container or in a fresh ubuntu:22.04
container, it works just fine
- DNS: Many other packages from the same URL installed just fine during the same install command
I have also tried switching from archive.ubuntu.com
to us.archive.ubuntu.com
, which did not solve the issue. I am currently trying to use mirror://mirrors.ubuntu.com/mirrors.txt
, but this results in installs that are several orders of magnitude slower.
I have found several other questions where the 403 error is consistent across all packages or repositories, due to firewall or DNS issues. This is a different issues, because I will have packages install successfully from the same repository moments before the failure.