docker-library / openjdk

Docker Official Image packaging for EA builds of OpenJDK from Oracle
http://openjdk.java.net
MIT License
1.14k stars 476 forks source link

Hash sum error when running apt-get from docker file #396

Closed TondiToday closed 4 years ago

TondiToday commented 4 years ago

I have been running into this issue when trying to run apt-get update in my docker file. Commands run

FROM openjdk:8-jdk
MAINTAINER example<example.com>
apt-get update

Output

Step 1/18 : FROM openjdk:8-jdk
 ---> 0bfcee65c8ca
Step 2/18 : MAINTAINER example<example.com>
 ---> Using cache
 ---> 374883f72201
Step 3/18 : RUN apt-get update --fix-missing && apt-get install -y build-essential bzip2 ca-certificates     libglib2.0-0 libxext6 libsm6 libxrender1 liblzma-dev && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
 ---> Running in b7ed60134872
Ign:1 http://deb.debian.org/debian stretch InRelease
Get:2 http://deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:3 http://deb.debian.org/debian stretch Release [118 kB]
Get:4 http://deb.debian.org/debian stretch-updates/main amd64 Packages [27.9 kB]
Get:5 http://deb.debian.org/debian stretch Release.gpg [2410 B]
Get:6 http://deb.debian.org/debian stretch/main amd64 Packages [7083 kB]
Get:7 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
Get:8 http://security.debian.org/debian-security stretch/updates/main amd64 Packages [517 kB]
Err:8 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
  Hash Sum mismatch
  Hashes of expected file:
   - Filesize:517188 [weak]
   - SHA256:5ffb04f6895bc41cdcc2943cd155b8676458c3c5353b32ff59cd43121ca0c997
   - SHA1:05ecd8469fc3074026e647fb8f8ccb524bbe423b [weak]
   - MD5Sum:823430fc81309bdc57ede5500d363934 [weak]
  Hashes of received file:
   - SHA256:9aeeb7d09d53dae9496c8e31b6fcedd1347b856b3b995edd4b6758a2a7ac14d2
   - SHA1:17f220423bb20c10a40c36f065ee57700d78df60 [weak]
   - MD5Sum:c02217d91a949ae8e911d644f748f47e [weak]
   - Filesize:11511 [weak]
  Last modification reported: Wed, 12 Feb 2020 15:52:19 +0000
  Release file created at: Wed, 12 Feb 2020 15:01:36 +0000
Fetched 7428 kB in 3s (2089 kB/s)
Reading package lists...
E: Failed to fetch http://security.debian.org/debian-security/dists/stretch/updates/main/binary-amd64/by-hash/SHA256/5ffb04f6895bc41cdcc2943cd155b8676458c3c5353b32ff59cd43121ca0c997  Hash Sum mismatch
   Hashes of expected file:
    - Filesize:517188 [weak]
    - SHA256:5ffb04f6895bc41cdcc2943cd155b8676458c3c5353b32ff59cd43121ca0c997
    - SHA1:05ecd8469fc3074026e647fb8f8ccb524bbe423b [weak]
    - MD5Sum:823430fc81309bdc57ede5500d363934 [weak]
   Hashes of received file:
    - SHA256:9aeeb7d09d53dae9496c8e31b6fcedd1347b856b3b995edd4b6758a2a7ac14d2
    - SHA1:17f220423bb20c10a40c36f065ee57700d78df60 [weak]
    - MD5Sum:c02217d91a949ae8e911d644f748f47e [weak]
    - Filesize:11511 [weak]
   Last modification reported: Wed, 12 Feb 2020 15:52:19 +0000
   Release file created at: Wed, 12 Feb 2020 15:01:36 +0000
E: Some index files failed to download. They have been ignored, or old ones used instead.
ERROR: Service failed to build: The command '/bin/sh -c apt-get update --fix-missing && apt-get install -y build-essential bzip2 ca-certificates     libglib2.0-0 libxext6 libsm6 libxrender1 liblzma-dev && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*' returned a non-zero code: 100
make: *** [build] Error 1

Ive tried many combinations of answers online to try and fix this. Has anyone who has run into the error been able to fix it.

tianon commented 4 years ago

Comparing the size of the received file versus the expected file (11511 vs 517188), this sounds like you've got a (corporate?) firewall/proxy/content blocker which is intercepting and replacing and/or truncating the requested file.

TondiToday commented 4 years ago

Have tried it on different networks. Same error persists

tianon commented 4 years ago

I can't reproduce: :confused:

$ docker pull openjdk:8-jdk
8-jdk: Pulling from library/openjdk
Digest: sha256:f815268bb2af51279b3361666c0b702e1a61f9eec83d817c6df49b78af768922
Status: Image is up to date for openjdk:8-jdk
docker.io/library/openjdk:8-jdk

$ docker run --rm openjdk:8-jdk apt-get update
Get:2 http://deb.debian.org/debian buster InRelease [122 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [49.3 kB]
Get:1 http://security-cdn.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:4 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]
Get:5 http://deb.debian.org/debian buster-updates/main amd64 Packages [7380 B]
Get:6 http://security-cdn.debian.org/debian-security buster/updates/main amd64 Packages [181 kB]
Fetched 8331 kB in 1s (7674 kB/s)
Reading package lists...
TondiToday commented 4 years ago

Okay, I solved this but it was a weird one. Currently trying to run docker on Mac OS Catalina 10.15.3. And we found that when you try to Curl to the URL which was failing it received an HTML file as opposed to a bitstream file. So we attempted ping the website directly and found that the native Screentime app on the OS was blocking the request for an unknown reason. Went ahead and disabled Content and Privacy restrictions and solved the problem. So NOT an openjdk problem, but if anyone else runs into the issue this is the fix.

realityworks commented 4 years ago

Okay, I solved this but it was a weird one. Currently trying to run docker on Mac OS Catalina 10.15.3. And we found that when you try to Curl to the URL which was failing it received an HTML file as opposed to a bitstream file. So we attempted ping the website directly and found that the native Screentime app on the OS was blocking the request for an unknown reason. Went ahead and disabled Content and Privacy restrictions and solved the problem. So NOT an openjdk problem, but if anyone else runs into the issue this is the fix.

This is the correct answer!