Docker Desktop Installer command line ignores --backend=wsl-2 parameter - docker

I am trying to automate the installation of Docker Desktop and some Linux containers on Windows 11 Enterprise but am unable to default Docker to use WSL 2.
According to the Docker Desktop Installer documentation the --backend=wsl-2 parameter should setup Docker to run using WSL2. But when I launch "Docker Desktop.exe" for the first time it shows the error: "Required Windows features(s) not enabled: Hyper-V. Switch to WSL 2 base engine?" This stops automation and requires manual entry before installing the Linux containers.
A log file entry in c:\program data\Docker Desktop\install-log-admin.1.txt appears to know that WSL 2 is desired as it has this entry:
Selected backend mode: wsl-2
The Powershell script I am using to run the installer is the following:
Start-Process -Wait -NoNewWindow -FilePath "Docker Desktop Installer.exe" -ArgumentList "install --backend=wsl-2 --quiet --accept-license " -ErrorAction Stop;
But if I launch the installer manually and keep the default options then Docker Desktop is setup to use WSL 2 and doesn't display this error.
Has anyone else run into this and found a workaround?
Note: Docker Desktop Version: 4.8.2
Things I've tried that have failed:
Using command-line instead of PowerShell
Changing wsl-2 to wsl or wsl2

Related

WSL2 Failed install docker desktop on Windows 11

When I use the win11 version and use wsl2 to distribute Docker Desktop 4.16.3,
Error prompt encountered during startup
enter image description here
Docker failed to initialize Docker Desktop is shutting down
Docker.Core.HttpBadResponseException: {"message":"2 errors occurred:\n\t* provisioning docker WSL distros: deploying \"docker-desktop\": importing WSL distro \"docker-desktop\": deploying WSL distro \"docker-desktop\" (\"C:\\\\Program Files\\\\Docker\\\\Docker\\\\resources\\\\wsl\\\\wsl-bootstrap.tar\" -\u003e \"C:\\\\Users\\\\15208\\\\AppData\\\\Local\\\\Docker\\\\wsl\\\\distro\"): exit status 0xffffffff\n\t* checking if isocache exists: CreateFile \\\\wsl$\\docker-desktop-data\\isocache\\: The network name cannot be found.\n\n"}
I try to change the version
Update system
set wsl default version
wsl --upate; wsl --shutdown
There is no way to solve it
you could run wsl --update then on the cmd as admin netsh winsock reset
then restart the machine worked for me

Power shell and GitBash shows the different docker image in windows OS

Hi I have installed docker desktop on my Windows machine.
If I list the docker image using Powershell or Docker Desktop or Cmd I can see the some set of docker images.
I can view the same in Git bash. I am not able to view the docker image listed by Powershell. But I am able to view some different image.
What config I need to update to get the same docker images from PowerShell and GitBash
How can I use the minikube using the docker image from my local system.
It is best to not mix up the Git for Windows bash shell, and the native Powershell.
The %PATH% might be different in a Powershell from Docker, and a bash shell from Git.
you can therefore follow "Getting started with Docker and Kubernetes on Windows 10" from Keith Mifsud, using WSL2 or Hyper-V
See also "Install Minikube in Windows 10 via Docker Desktop 2021 Version"

Not able to start docker Desktop in Windows

I am not able to start the Docker container in Microsoft Windows 10 profession. As I found the cause of this error is due to the docker engine is failing to start.
After installing docker I am able to run only the docker version command.
-> docker --version
As I found the error which is showing docker daemon is not running in windows while running any other docker commands on CMD.
I also enabled (checked) the Hyper-V option in "Turn Windows features on or off" in the Control panel -> Programs -> Turn Windows features on or off.
The error is related to the daemon part:
In the default daemon configuration on Windows, the docker client must be run elevated to connect.
We can switch the Docker daemon as an elevated user in order to run the docker daemon in the Windows professional:
Run below command with Windows Powershell as administrator:
Run the PowerShell command: -
& 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon
OR
You can run the below command on CMD as administrator:
Run the CMD command: -
"C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchDaemon
My Docker Desktop failed to start after I forced it to exit while updating (it stuck during the update that's why I had to do it). No solution on the Internet helped me until I ran into this Powershell command:
wsl -l -v
It listed the following:
* Ubuntu-18.04 Stopped 2
docker-desktop Uninstalling 2
docker-desktop-data Stopped 2
It kept saying "Uninstalling" even after rebooting the whole system.
What I did was:
wsl -t docker-desktop
It terminated docker-desktop and made the problem gone.
delete %appdata%\Docker\settings.json and let Docker to create a new one
You should check WSL:
Execute "wsl -l -v" at the command prompt.
If the result is like this:
Then execute "wsl --shutdown" on the command line.
Then execute "wsl -l -v", you will see:
Then start Docker Desktop.
This solved my problem.
Make sure to download the Linux Kernel Update Package and then try restarting Docker Desktop.
Download from here
Just share my experience how I solved the problem with "docker failed to start" or similar problem. I found some mess with my Win10 Home edition, despite the fact that all checkes regarding Hyper-v, wsl and others passed I got failed to start docker engine. So, I tried to install one of the old version (4.4.4), not the newest one. An voila it installed wsl2 and started without any problems!
Hope this could help someone who's tried all solutions (for example, deletion of the %appdata%\docker folders) :)
I was getting the same exact issue and a solution was provided from thread The attempted operation is not supported for the type of object referenced." error after Windows Update fixed my problem. I had tried everything before this solution. To keep it simple just follow the below steps -
Copy below snippet
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\0408F7A3]
"AppFullPath"="C:\Windows\System32\wsl.exe"
"PermittedLspCategories"=dword:80000000
Save it as a file wsl.reg
Execute the file to update the wsl registry
restart docker desktop
these steps are basically done to do some changes in the registry of wsl distribution that is installed standalone or by docker.
Using PowerShell gave me a right direction. All restarts and re-install with deletion didn't work.
wsl -l -v showed list of three processes but wsl -t docker-desktop responded with "There is no distribution with the supplied name." only. wsl --shutdown either didn't work.
Solution is next door wsl --unregister docker-desktop . After this all went fine.
I ran the following command which resolved the issue for me.
wsl --unregister docker-desktop
Please make sure your OS type requires WSL or Hyper-V to run docker as per this official link 👉 https://docs.docker.com/desktop/install/windows-install/
For my case, I am using Windows 11 Home OS, and it requires WSL (Windows Subsystem for Linux) to run docker. So that I installed WSL on my system.
Follow this link to install WSL 👉 https://learn.microsoft.com/en-us/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package
After that restart your system, then open docker (It may take up to 10 secs to start)
Hope it may solve your issue✌️

Docker for Windows and WSL1 to Work together

Exactly the same problem as Ubuntu WSL with docker could not be found
$ docker
The command 'docker' could not be found in this WSL 1 distro.
We recommend to convert this distro to WSL 2 and activate
the WSL integration in Docker Desktop settings.
See https://docs.docker.com/docker-for-windows/wsl/ for details.
But my requirement is different -- I want to
stick with WSL1 (for reasons beyond this topic)
and use Docker for Windows as-is
I.e., I have WSL1 and Docker for Windows installed parallel to each other. This is my current info:
C:> ver
Microsoft Windows [Version 10.0.18363.1379]
C:> wsl -l -v
NAME STATE VERSION
* Debian Running 1
I don't see integration in "Resources -> WSL Integration", and I don't have WSL2 backend enabled in Docker Desktop settings.
Just that I'm getting the above problem -- my docker works anywhere, in CMD, Powershell, git-bash, etc, just not in my WSL.
All solutions that I found are to install Docker for Windows within WSL1 or WSL2, but I want to keep everything as is -- WSL and Docker for Windows installed parallel to each other.
Any solution for that?
The command 'docker' could not be found in this WSL 1 distro.
We recommend to convert this distro to WSL 2 and activate
the WSL integration in Docker Desktop settings.
This means in WSL2, it has a real linux kernel which is required to install docker daemon, then in docker-desktop you could have chance to set docker daemon in WSL2. Otherwise, the docker daemon is running in Hyper-V machine. But, if you stick in WSL1, no chance to run docker-daemon in WSL, so the only option is running docker daemon in Hyper-V machine.
Although above is the fact, still we have chance to let you operate docker ps, docker pull etc. in WSL1 bash just like you operate through CMD, Powershell, git-bash, that is allow Docker to accept requests from remote hosts.
For your case, the steps maybe next:
1. Expose docker daemon in docker desktop settings as next, then click Apply & Restart:
2. Install standalone docker client in WSL1:
$ wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.5.tgz
$ tar zxvf docker-20.10.5.tgz
$ cd docker
3. Set default docker daemon:
$ export DOCKER_HOST=tcp://localhost:2375
4. Verify docker client command:
$ ./docker info
Just FTA, this is the quick hacky workaround that I found, while trying to solve it myself
Change the C:\Program Files\Docker\Docker\resources\bin\docker file to
#!/usr/bin/env sh
#
# Copyright (c) Docker Inc.
binary=$(basename "$0")
"$binary.exe" "$#"
Then docker can work anywhere now, in CMD, Powershell, git-bash, and as well as WSL1.
Note that this hacky workaround is specially for the situation described in OP, might not work for anything else.
I ran the same issue with Ubuntu 20 Distro when trying to use Docker. Below are steps i followed to resole it:
1- I went to microsoft Store and downloaded a recent distro version of the distro, that was Ubuntu 22.04
2- On powershell as admin, i ran the command wsl -l -v to make sure i have the new version
PS C:\WINDOWS\system32> wsl -l -v
NAME STATE VERSION
* Ubuntu Stopped 1
Ubuntu-22.04 Stopped 2
docker-desktop-data Stopped 2
docker-desktop Stopped 2
3- i ran the command: wsl --set-default Ubuntu-22.04 to use wsl 2
I wan now able to use Docker on WSL 2

I can't run Docker ToolBox on Windows 7

I can't start docker toolbox on windows 7.
This are few steps i did.
1) I download Docker Toolbox from official site.
2) Installed it
3)Installed virtualbox.exe from docker directory.
4) When i run QUICKSTART DOCKER TERMINAL i get this after few settings:
Looks like something went wrong in step ´Setting env´... Press any key to continue...
So i can't run it. What shall i d0?
Also i can't start start.sh
I can see docker --version from git,cmd, and created by docker in vb linux.
Also i can run hello-world from linux console from vb.
But how can i start docker?
Basically i don't understand where i need to work with docker from.
From my windows termianl or only from vb linux terminal
run as administrator a cmd and run this command
"C:\Program Files\Git\bin\bash.exe" --login -i "C:\Program Files\Docker Toolbox\start.sh"
it will be from your vb linux terminal.. everything is present inside it to run your docker.
the purpose of toolbox is to use it on the unsupported version on your machine via the virtual box..

Resources