Can't install Docker - Hash sum mismatch (Ubuntu 18.04, Vagrant, Virtualbox)

感情迁移 提交于 2021-01-21 05:09:30

问题


I just can't install Docker in a fresh image of Ubuntu 18.04 (in Virtualbox, using Vagrant). I am using the instruction from the official site:

https://docs.docker.com/install/linux/docker-ce/ubuntu/

Or the short command from https://github.com/docker/docker-install:

curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh

And always got the same errors - Hash sum mismatch:

Failed to fetch https://download.docker.com/linux/ubuntu/dists/bionic/pool/stable/amd64/docker-ce_19.03.8~3-0~ubuntu-bionic_amd64.deb  Hash Sum mismatch
   Hashes of expected file:
    - SHA512:600f2d9b51024e5866a6256f2d08b4e733a6c8428e334d81de483a7138cbe9db00e8d67673a88d46c80ef0aa673e2f0183f8fd58226575a3a6a843f955c49e2a
    - SHA256:22fe06851dde23200c835641e234760bbb60b79abc3b2a1fbbd1a9b0f1a2e9d0
    - SHA1:7292df34a82e58cab0e45af61036ec19c81eb199 [weak]
    - MD5Sum:8d62aefa851deb2f0739b4a1fd232322 [weak]
    - Filesize:22879338 [weak]
   Hashes of received file:
    - SHA512:265e3e4f877e4d060098d88527258335a08c9b421fabd5573bb5c951fd337c2d157c418132ff6a54568e85c6bd0da3e1b66c51196410016b4b409d1cef2df4cd
    - SHA256:3d15d2e2a7bacc0840aea09400970328d853eb369585e97ce33c8bebbc5c4d37
    - SHA1:da5b39535801e35493cd2f7c6f2b176263bd7da4 [weak]
    - MD5Sum:a4e2e8ec89b2d98c218b3931d7845f50 [weak]
    - Filesize:22879338 [weak]
   Last modification reported: Wed, 11 Mar 2020 19:46:26 +0000
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

回答1:


I'm also seeing this problem with a large number of packages in multiple Linux distributions. All in VirtualBox 6.1.6 on Windows 10. Errors include Hash Sum mismatch, LZMA compression corruption, GZIP corruption, and Squashfs decompression failures. Basically anything that involves a checksum.

It seems unlikely that I have downloaded 4 distributions (and dozens of packages) and they're all faulty. Disabling Hyper-V does seem to improve things.




回答2:


I had issues with Windows 10, Update 2004. I would get checksum mismatches when updating the software repository index and on installs.

The problem was actually due to networking and the "autotuning" parameter of Windows.

You can check the current state in an elevated command prompt:

netsh int tcp show global

Receive Window Auto-Tuning on normal created problems. By setting it to disabled the problem is gone for me.

You can change it by executing the following in an elevated command prompt.

netsh int tcp set global autotuninglevel=disabled



回答3:


OK guys, as I can understand, this is the fault of the Virtualbox. Because I don't see this problem in Vagrant when I using the hyperv provider at the same box.

The version of the Virtualbox is 6.1.4 r136177 (Qt5.6.2).

I have check how virtual OS download the packages (just by download it by direct link using wget) and I saw that hashsum of the downloaded package is really different from the original (but the size is absolutely equal). I have download the same package in the host OS, and the hashsum has match to original.

Output error and the hashsum of the downloaded package inside the virtual OS (different from original):

The hashsum of the downloaded package at the host OS (equal to original):




回答4:


I was also having these issues constantly!

My setup was Virtual Box 6.1.6 with Vagrant 2.2.7 running on a Win10 host.

Using the above idea that the issue might be inherent to Virtual Box rather than Ubuntu, I uninstalled Virtual Box 6.1.6 then installed an older version of Virtual Box (6.0.10) and re-installed Vagrant 2.2.7. I also uninstalled Hyper-V from Windows.

With these system and software changes made, the automatic Docker provisioning of Vagrant worked as expected without any hash mismatch messages. This worked for me and I hope it helps someone else also.




回答5:


For anyone still having issues with this, I managed to get it working by disabling HyperV (as most people have already suggested). However, on my setup, disabling HyperV using the mentioned approaches didnt actually disable HyperV since my windows machine used HyperV for both CredentialGuard and Secure Boot, both of which needed to be disabled before HyperV was actually fully disabled

If running systeminfo.exe in an elevated terminal shows A hypervisor has been detected. Features required for Hyper-V will not be displayed, then HyperV is not fully disabled. Disabling credential guard and secure boot coupled with a few restarts (and all the commands to disable HyperV that have already been mentioned) solved all issues for me.

Just for reference, if HyperV is fully disabled, you should see

Hyper-V Requirements:      VM Monitor Mode Extensions: Yes
                           Virtualization Enabled In Firmware: Yes
                           Second Level Address Translation: Yes
                           Data Execution Prevention Available: Yes

when running systeminfo.exe




回答6:


Same problem here in a fresh Debian VM (VBox) amd64 (32GB VDI).

sh get-docker.sh
...

E: Failed to fetch https://download.docker.com/linux/debian/dists/buster/pool/stable/amd64/containerd.io_1.2.13-1_amd64.deb  Hash Sum mismatch
   Hashes of expected file:
    - SHA512:e0f8eb0ed3bd881bf5f278f3736da3e4fb05410014a0103301c135a33061945e013bcf8a9cd704d9d6b4fa088d478ebea27e86e466889d0194a8cbb77e94efdf
    - SHA256:a4f244216e54a8a47f2dc5c57acb4cb48a779c54a8588ea2d55c40a57092baf6
    - SHA1:90611afda0acabae485f871b09e4c1eba0ac4dc0 [weak]
    - MD5Sum:78a039cf82b1bd4a285114bdd030982e [weak]
    - Filesize:20114318 [weak]
   Hashes of received file:
    - SHA512:41c516c077d9941b55b605d4c83a9462c2ec52089f8af55618e5335da7d272d33d57fdd14a51b5a5e433ad6d9671e1a0063f9edeaa8c31525f56474b6ac1d875
    - SHA256:57080e5482d92e74c3095b948fc0ba827f43b7b03c8825e5a64b7ef058b5434c
    - SHA1:4f114ab71f4622f5785da726b822ad213ec77d44 [weak]
    - MD5Sum:9a5d02cb5624219e6715875cc4bc8673 [weak]
    - Filesize:20114318 [weak]
   Last modification reported: Tue, 03 Mar 2020 04:24:01 +0000
E: Failed to fetch https://download.docker.com/linux/debian/dists/buster/pool/stable/amd64/docker-ce-cli_19.03.8~3-0~debian-buster_amd64.deb  Hash Sum mismatch




回答7:


Ok, so here it is.

After studying the most helpful @Kurt Le Breton's answer and repeated testing, my conclusion is as follows.

Virtual Box latest is currently 6.1.12 and this gives the said Hash sum mismatch problem. In fact it seems the entire 6.1.xx gives this problem.

So go to the previous 6.0 version. But when you issue this vagrant up command, vagrant spits the following error right on your face.

There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["startvm", "40f50d63-6d70-4ac9-b0d6-02dcf1cdce7c", "--type", "headless"]
Stderr: VBoxManage.exe: error: Call to WHvSetupPartition failed: ERROR_SUCCESS (Last=0xc000000d/87) (VERR_NEM_VM_CREATE_FAILED)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole

Now to resolve this, you need to fiddle with Hyper-v settings. You need to run the following command as an administrator.

bcdedit /set hypervisorlaunchtype off

After you run that command, you need to restart your pc. With this your Vagrant should run without complaining, and docker should be installed on your VM without any Hash Sum Mismatch error.

I tested with 6.0.24, which is the latest 6.0 version, and things look file so far.

But then, there is a catch. Once you set hypervisorlaunchtype to off, docker desktop would not launch. You get this error now. And you will get this error when you are trying to launch Docker on windows for Linux containers. For windows this is not a problem.

An error occured. Cannot enable Hyper-V service.

So now you need to reset this back to its original state.

bcdedit /set hypervisorlaunchtype auto

Note auto this time instead of off.

Again, you need to be an admin to run this, and after you run, you have to restart your pc.

So the workflow should be to first set that to off, launch your vms and provision them with docker using vagrant, then finally, set hypervisorlaunchtype back to auto.




回答8:


I encounter the same issue and tried above solutions. none of the them works on my cases. I change box to Debian. All issues are gone.




回答9:


I had the same problem with Docker or PHP (Debian sury depo - Sury.org)

HyperV was already disabled on my Windows. But I always haved this problem under VirtualBox.

I resolved it in Virtualbox machine configuration :

"System" > "Processor" > "Enable PAE/NX" option.

Then reboot your virtual machine, launch apt install (or upgrade) command and it should works.




回答10:


For anyone who is still getting this error, it's been fixed in the latest version of VirtualBox (since at least version 6.1.16). Check if your version is out of date.




回答11:


It is the same error as me. Hash Sum mismatch...

After I initialized WSL2, Oracle VM ware worked fine.

-Disable Windows Hyper-v



来源:https://stackoverflow.com/questions/61027483/cant-install-docker-hash-sum-mismatch-ubuntu-18-04-vagrant-virtualbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!