What you see
E: Failed to fetch http://deb.debian.org/debian/dists/bookworm/main/binary-amd64/by-hash/SHA256/... Hash Sum mismatch
Hashes of expected file:
- Filesize:8789460 [weak]Common causes
- A public mirror caught in the middle of a sync, serving new indexes with old release files or the other way round.
- A transparent proxy serving a stale or truncated copy.
- A corrupted local apt list cache in a reused image layer.
How to fix it
- 01
Clear the lists and retry
Start from a clean list cache.
Dockerfile RUN rm -rf /var/lib/apt/lists/* \ && apt-get update \ && apt-get install -y --no-install-recommends curl - 02
Retry downloads
apt can retry failed fetches.
Dockerfile RUN apt-get -o Acquire::Retries=5 update - 03
Use a cache that serves consistent snapshots
A cache that updates release files and indexes together avoids half-synced states.
Dockerfile RUN sed -i "s|http://deb.debian.org|http://acme.cacheport.cc/apt/deb.debian.org|g" /etc/apt/sources.list.d/debian.sources