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

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?

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.

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):

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.

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

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.

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

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.

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

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.

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.

It is the same error as me. Hash Sum mismatch...
After I initialized WSL2, Oracle VM ware worked fine.
-Disable Windows Hyper-v

Related

Any reason not to remove Docker as default WSL distro?

I have the latest version of Windows Subsystem for Linux (WSL) installed, but when I run wsl from the command line I get the following error:
An error occurred mounting one of your file systems. Please run ‘dmesg’ for more details.
I hunted down a few possible explanations and one is the possibility that Docker is set as my default wsl. Sure enough, when I run wsl -l -v, the response is:
NAME | STATE | VERSION
* docker-desktop-data | Stopped | 2
docker-desktop | Stopped | 2
To correct this, I am told to change the default from Docker to something else with the command wsl -s distroName where “distroName” should be changed to … something.
So I have two questions:
What should I type instead of “distroName”?
Will Docker Desktop still perform as intended if I do this?
If you're not using WSL for anything other than Docker Desktop, then it really doesn't matter.
But since you attempted to run wsl, it sounds like you may want to try it out. In that case, you should definitely install a WSL distribution that is meant for interactive use.
The docker-desktop and docker-desktop-data distributions aren't really intended to be accessed directly by the user, but one of them will get set as default if you don't have any other distribution installed. There's a proposal to have a way for Docker to set these as "hidden" so that WSL wouldn't automatically set either as default.
What should I type instead of “distroName”?
First, install a user distribution. Which one you choose is up to you, but I typically recommend Ubuntu for first-time installs. When installing WSL on recent Windows releases, it should be the default.
It's installable via the Microsoft Store -- Just find the one that says "Ubuntu" (with no version number). It will install the latest release.
Then, in PowerShell;
wsl --set-default Ubuntu
Will Docker Desktop still perform as intended if I do this?
Absolutely -- It's really an error/corner-case/oversight that docker-desktop-data ever gets set as default anyway, which is why it's nice that the WSL team is considering a method to prevent this.

Docker under WSL without Docker Desktop

This is the question regarding running Docker from within WSL, without Docker Desktop. It is doable for WSL2, so the focus of this question is on WSL1 specifically. Of my researches,
Some says "the Docker daemon cannot run directly on WSL", while
Another article says Docker can be run "seamlessly in Windows Subsystem Linux", with the help of Docker Community Edition 17.09.0, as "A crucial change was made to the WSL kernel that enables the usage of cgroups which Docker needs to manage your system’s resources into containers."
My docker is 20.10.5 under debian bullseye. Would it be still good?
I tried it, and got:
iptables can't initialize iptables table `nat': Table does not exist
and the answer to Iptables v1.6.1 can't initialize iptables table `filter' Ubuntu 18.04 Bash Windows is that,
According to the Microsoft WSL page on github.com, iptables isn't supported.
https://github.com/Microsoft/WSL/issues/767
But that's more than 4 years ago, and since it has been possible later in year 2019, I'm wondering what the latest status is.
WSL1 - The little engine that could (link included since that reference may only be understood by a limited audience).
Unfortunately, in the case of Docker, the WSL1 engine seems to have run out of steam. In reading that blog post that you reference, and the corresponding Github thread, I'm pretty amazed at just how far along folks did get with running Docker. I had never seen that before.
However, if you read the full comments on the Github thread, it appears that the results were fairly limited. Placing these excerpts in order:
[2018-04-23] I'm glad to say Docker daemon finally runs on WSL. I'm testing on build 17134. ... The last docker-ce version that works right now on build 17134 is 17.09.0. Anything after that fails on extracting the docker images.
Note that it had to (and still has to) be run in a WSL1 instance running as a Windows admin.
[2018-0612] Unfortunately, docker-compose still doesn't work.... There is a problem with iptables which is not fully supported via WSL yet.
(Which you've run into, although I didn't see that. Perhaps the "admin" thing?)
[2018-07-09] Yeah, I recently mentioned it on Twitter and got a major "we aren't supporting this, we highly advise against it" message from our former WSL PM.
[2018-11-13] WSL PM here. As mentioned in the above comment, we have improved Docker support in recent builds of WSL. Most (if not all) versions of docker-ce work with WSL. We're working on a large set of changes for WSL currently. As part of those changes, we are looking at adding native Docker support in WSL. I will add to this thread and other issues on Docker support when I have additional updates to share
It doesn't seem like this ever progressed, since the PM never posted again in the thread, at least.
[2019-04-18] Like others have pointed out, running docker 17.09 works. Anything later fails with different errors. It might be that newer docker versions are using other syscalls not yet implemented by WSL.
There are some other messages scattered in here about running with --network host (for the client) or --iptables=false (for the daemon).
[2019-08-04] Windows Insider Fast Ring build (>=18917) via WSL2, latest docker/docker-compose is running native in WSL Linux.
And in late 2020, the thread died off.
In a test WSL1 Ubuntu 20.04 instance, I was able to get hello-world running, but nothing more. Running a busybox or ubuntu image (with or without an interactive terminal) failed with:
Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: waiting for init preliminary setup: EOF: unknown.
Once the focused shifted to WSL2 and the real kernel, it doesn't appear to me that the WSL team has made any more progress advancing WSL1's pseudo-kernel syscall translation layer.

Docker not starting on Windows 11 with WSL 2

I'm trying to setup docker with WSL 2 to run a Dockerfile. I downloaded Docker Desktop, and when I tried to follow the quick start guide, I got the following error:
docker: error during connect: This error may indicate that the docker daemon is not running.: Post "http://%2F%2F.%2Fpipe%d2Fdocker_engine/v1.24/containers/create?name=repo": open //./pipe/docker_enginer: The system cannot find the file specified.
I set com.docker.service to run in the Task Manager, and have run:
“c:\Program Files\Docker\Docker\DockerCli.exe” -SwitchDaemon
I have also quit Docker Desktop and reopened it in admin mode, and I still get the message that Docker Desktop has stopped.
Please let me know if there's any other options, thanks!
I managed to solve the problem in this way:
delete config file AppData/Roaming/Docker/settings.json
start Docker Desktop (it will create new default settings.json)
You need to re-configure settings, so it is also good idea to save the old settings.json and compare settings with the new one.
If you are running Docker Desktop for Windows 4.5.0 then you should be aware of an existing issue where the default backend selected after installing is not the correct one.
You can switch to the correct backend manually by editing the file located at: %AppData%\Docker\settings.json (full path: C:\Users\%UserName%\AppData\Roaming\Docker\settings.json) and at the bottom of the file change the value for the wslEngineEnabled field to true. After that Docker Desktop should start correctly.
Similar issue and solution is mentioned here by the user mccaa25.
latest version 4.5.0 It won't work for me too, for me downgrade to 4.4.4 it worked. It may be problem with the latest version
for released note and older version Here
Note: You can install an older version and update to latest version 4.5.0
Wow! I spent multiple days trying to get Docker for windows 11 to work. What finally did it was downgrading to version 4.4.4 as #GinglrBell recommended. Here's a link Docker version 4.4.4.
Make sure WSL is installed and virtualization is enabled. If you try to open WSL and you get an error telling you to enable virtualization in BIOS, run this command as Admin in powershell: bcdedit /set hypervisorlaunchtype auto (Docker src). Then restart your PC.
I hit this issue today, and the steps below are what worked for me - the gist is that I needed to install WSL 2 beforehand. Most of my steps were derived from here:
open powershell as admin
wsl -l -v # Windows Subsystem for Linux has no installed distributions
install linux kernel update from here # in my case, x64-based
wsl --set-default-version 2
wsl --list --online # shows several linux distributions, I picked a recent one
wsl --install -d Ubuntu-20.04 # then create default linux user name and password
install windows docker desktop from here # now starts successfully
Manged to switch to Windows Containers. (Docker v4.9.0)
What I did was to change the following in the settings.json:
"useWindowsContainers": true,
"wslEngineEnabled": true,
Also set security on folder:
C:\ProgramData\Docker (I set "Everyone" full control.)
After that I used the "Switch to Windows Containers"-feature from the task-bar icon content menu
I tried Janne Rantala's method.
But the same problem occurs again after several days.
My final solution is to uninstall Docker Desktop, then download and run the installation file as an administrator.
Then the problem no longer appears again.
I was able to resolve this issue on my machine by installing the Linux kernel update package as described in the Microsoft guide
I have been having some Docker setting up troubles for a fair amount of time. I think I had to just make sure I removed all references of Docker. After buying Windows 10 pro I still had issues, I did have to look into the following folders:
C:\Users\%UserName%\AppData\Local\Temp\Docker
C:\Users\%UserName%\AppData\Roaming\Docker
I also deleted the Docker file in my programfiles folder
Navigated to said file and deleted Docker files.
Used the docker installer, checkboxes (to use wsl2).
I was faicing the same issue and resolved. I have just open Microsoft Store application and after that opened the docker and its working fine. This is wired but sharing this so it might helps someone.
I solved this issue by enabling the windows feature "Windows Hypervisor Platform" and restarting my computer.
I installed Docker Desktop v4.16.2

Docker create command hangs on "Waiting for host to start"

Docker hangs when I try to create a docker node
I am trying to set up a docker node as per step 4 of the instructions on docker.com. Unfortunately, Whenever I run the "create" command in the command prompt, the process hangs on
(testNode1) Waiting for host to start...
The instruction set is roughly as follows:
Enable HyperV (done)
Set up external network switch (done)
Reboot (done)
Create nodes (hangs)
The document explicitly states that step 3 is included to prevent exactly this error from happening. However, I have completed that step, and I still encounter this error.
Solutions I have tried
Other sources have suggested that I'm either targeting the wrong network switch, or that the one I've created is not set to "external". I have verified that the switch is set to "external" and that the correct network switch is being targeted, so that does not seem to be the problem.
I have also made sure to restart my machine a few times already, so I doubt another reboot on its own will help.
I also left it running for a day to see if it would eventually resolve itself, but it did not.
Additional details
The command I'm using is:
docker-machine create -d hyperv --hyperv-virtual-switch "VirtualSwitchName" testNode1
I am using Docker version 18.09
I am using Windows 10 Enterprise.
The node is hosted on Hyper-V
Make sure the Docker version is compatible with the Windows version
There are multiple versions of Docker Enterprise. Each successive version has improved functionality, but each version also requires a more up-to-date version of Windows 10.
For example, if you are trying to run Docker 18.09, then you need Windows 10 version 1809 or higher. Docker 18.09 is simply not compatible with earlier versions of Windows 10.
How to check for a compatible Docker version
There is a useful chart here detailing which versions of Docker are compatible with which operating systems. This will tell you what the highest version of Docker is that you can run based on your current OS.
To check your OS version, open your command prompt and type "winver". This will bring up a popup telling you what version of windows you are running (for example, Windows 10, Version 1709). Use this and the above chart to determine if your current version of Docker is compatible with your current OS.

(using WSL ubuntu app) system has not been booted with system as init system (PID 1). Can't operate [duplicate]

This question already has an answer here:
Enable Systemd in WSL 2
(1 answer)
Closed 2 months ago.
I'm a very first user of Ubuntu. I failed to install Ubuntu in wmware ,so I installed Ubuntu application in Microsoft app store and everything was quite all right.
But when I insert shutdown or halt command to power off my ubuntu I kept getting 'system has not been booted with system as init system (PID 1). Can't operate' error message.
I tried to using docker following with this link (https://blog.jayway.com/2017/04/19/running-docker-on-bash-on-windows/) but I failed after going to Number 2 process many times. I'm not sure my failure is because of installing docker toll box instead of normal one. (my computer is just windows 10. not a windows pro)
I think I have to try other thing. If you don't mind me asking, how can I slove this problem?
(and one more. If I just click 'X' button at the top of right side, is it different with shutting down Ubuntu using 'halt' or 'shutdown' command?
Thank you
I found this useful: https://linuxhandbook.com/system-has-not-been-booted-with-systemd/
In my case
# start docker using systemctl
sudo systemctl docker start
# returns:
#
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
The basic advice is:
# check if your system is using `systemd` or `sysvinit`
ps -p 1 -o comm=
If the command doesn't return systemd, and in my case, Ubuntu-20.04 on WSL, the command returned init, then use the command pattern
# start services using sysvinit
service docker start
This works for me.
Based on this: https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/
systemd is now available in WSL Version 0.67.6 or higher.
To enable:
Open a command prompt:
# CHOOSE option A or B:
# A. check your version and ensure it is 0.67.6 or higher
wsl.exe --version
# B. run WSL update if the version is low
wsl.exe --update
Open a WSL prompt:
sudo nano /etc/wsl.conf
Add this to wsl.conf and save the file:
[boot]
systemd=true
Go back to the command prompt:
# warning: this will kill any shells/processes you have running!
wsl.exe --shutdown
First of all, Ubuntu installed via MS Store is using WSL (Windows Subsystem for Linux) Technology. It simply means there is no virtualization, Windows and Linux kernels are living side by side (the Linux kernel is not fully implemented yet).
So if you are trying to "shut down your Ubuntu", you would turn off the whole computer just like the Windows does. But in this case, WSL doesn't apparently have rights to do that.
In other words, you can look at your Ubuntu bash window just like any other terminal, like e.g. CMD or PowerShell.
When you start a program in the WSL (Ubuntu), you can see it also in Windows Task Manager - that's just a proof, that there is no virtualization.
Regarding docker:
If I'm not mistaken Windows 10 Home doesn't provide Hyper-V virtualization. It means you'll have to use a different one e.g. by using VirtualBox. In order to make it work, I can recommend you to follow this tutorial and especially for VirtualBox please check this answer here
Hope it helps :)

Resources