The following line fails when building Docker images on Windows 11, WLS 2 Debian and Ubuntu
RUN apt-get update && apt-get install -y \
git
The above line fails with errors, an example is listed below.
1.736 Err:5 http://deb.debian.org/debian bookworm-updates/main amd64 Packages
1.736 Hash Sum mismatch
1.736 Hashes of expected file:
1.736 - Filesize:2468 [weak]
1.736 - SHA256:927b6341d565b3434080f1c124027f06a68698bec3c1297a93b11ddb78558e21
1.736 Hashes of received file:
1.736 - SHA256:726fe922667ae45e647814b17383d2dfeb08d0eac1e13f3f551a1a36b77148e9
1.736 - Filesize:2468 [weak]
1.736 Last modification reported: Tue, 10 Sep 2024 20:06:12 +0000
1.736 Release file created at: Tue, 12 Nov 2024 20:16:26 +0000
1.777 Ign:6 http://deb.debian.org/debian-security bookworm-security/main amd64 Packages
2.863 Get:6 http://deb.debian.org/debian-security bookworm-security/main amd64 Packages [204 kB]
2.993 Fetched 9250 kB in 3s (3557 kB/s)
2.993 Reading package lists...
3.405 E: Failed to fetch http://deb.debian.org/debian/dists/bookworm-updates/main/binary-amd64/by-hash/SHA256/927b6341d565b3434080f1c124027f06a68698bec3c1297a93b11ddb78558e21 Hash Sum mismatch
3.405 Hashes of expected file:
3.405 - Filesize:2468 [weak]
3.405 - SHA256:927b6341d565b3434080f1c124027f06a68698bec3c1297a93b11ddb78558e21
3.405 Hashes of received file:
3.405 - SHA256:726fe922667ae45e647814b17383d2dfeb08d0eac1e13f3f551a1a36b77148e9
3.405 - Filesize:2468 [weak]
3.405 Last modification reported: Tue, 10 Sep 2024 20:06:12 +0000
3.405 Release file created at: Tue, 12 Nov 2024 20:16:26 +0000
3.405 E: Some index files failed to download. They have been ignored, or old ones used instead.
My system is currently running Windows 11 23H2
Docker Desktop v4.35.1
wsl --status
Default Distribution: Debian
Default Version: 2
Windows Subsystem for Linux was last updated on 2024-02-20
WSL automatic updates are on.
Kernel version: 5.10.102.1
WSL 2 - Debian Image
$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
$ uname -a
Linux HOSTNAME 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 GNU/Linux
$ docker -v
Docker version 27.3.1, build ce12230
I tried the suggestions to disable Hyper-V (bcdedit /set hypervisorlaunchtype off) as per https://stackoverflow.com/a/62510208 which did not work.
The Solution
The solution was to add the following line to my Dockerfile before the installation steps (see https://gist.github.com/trastle/5722089)
RUN echo "Acquire::http::Pipeline-Depth 0;Acquire::http::No-Cache true;Acquire::BrokenProxy true;" >> /etc/apt/apt.conf.d/99fixbadproxy
References
https://gist.github.com/trastle/5722089
https://askubuntu.com/a/709568
https://stackoverflow.com/a/62510208
Comments
0 comments
Please sign in to leave a comment.