An apk add inside an Alpine build could not reach the package mirrors. The fetch fails with a temporary/network error - DNS, a flaky mirror, or no outbound network for that build step.
What this error means
A RUN apk add ... step fails with temporary error (try again later), Could not connect to ... dl-cdn.alpinelinux.org, or fetch ... failed. The same Dockerfile builds fine when the network is healthy.
docker
#6 1.20 fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/main/x86_64/APKINDEX.tar.gz
#6 1.45 ERROR: unable to select packages:
#6 1.45 temporary error (try again later)
Common causes
A flaky or slow Alpine mirror
The CDN mirror can briefly fail or time out, so the index fetch (and thus package selection) fails. This is usually transient.
DNS resolution failing in the build
If the builder cannot resolve dl-cdn.alpinelinux.org, every fetch fails before it even connects.
No outbound network for the step
A --network=none step, or a runner with restricted egress, leaves apk with nothing to fetch.
How to fix it
Update the index and retry within the step
Refresh the index and let the package manager retry the fetch.
Dockerfile
RUN apk update && apk add --no-cache ca-certificates curl
Confirm egress and DNS for the build
Make sure the build step has network and can resolve the mirror.
How to prevent it
Use apk add --no-cache and keep package lists minimal.
Ensure the build step has outbound network and working DNS.
Consider a pinned internal mirror for high-volume CI.
Frequently asked questions
What causes "apk "temporary error (try again later)""?
The CDN mirror can briefly fail or time out, so the index fetch (and thus package selection) fails. This is usually transient.
How do I fix apk "temporary error (try again later)"?
Refresh the index and let the package manager retry the fetch.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.