for-win
for-win copied to clipboard
Cannot install "DDev with Docker inside WSL" for non-administrative users
Description
If the ps-script is running as administrator, wsl -l -v is empty, because I'm the administrator and not the user.
To be more precise:
My user on my Windows machine is not an administrator and therefore running the script as administrator, won't list my normal users wsl distributions. On the other hand, running ths script with normal privileges, results in permission-errors for obvious reasons.
Long story short: I've not been able to install ddev with docker inside for a non administrative windows user
Reproduce
- Install Windows (latest Win 11 in my case)
- Make a administrative user account
- Make a standard user account
- Login to the standard user account
- Install wsl:
- Follow the instructions and stop at 2. "In an administrative PowerShell run this PowerShell script by executing:" : https://ddev.readthedocs.io/en/latest/users/install/ddev-installation/#wsl2-docker-ce-inside-install-script
- Handle following occuring error thrown in the script:
if (wsl bash -c "test -d /mnt/wsl/docker-desktop >/dev/null 2>&1" ) {
throw "Docker Desktop integration is enabled with the default distro and it must but turned off."
}
7.1: I handled this by deleting the lines. Docker Desktop isn't installed and never was.. so this error is confusing and breaking, but I already asked for it in Issue 13726 8. Open an administrative power shell 9. TRY to install the script
2 possible outcomes:
- Run as administrator:
- Script runs through, but at the end nothing happens, because administrator doesn't have any wsl installations
- Run as normal user:
- Script crashes at the end due to permission errors (expected for obvious reasons)
Expected behavior
Installation of ddev and docker inside wsl
docker version
none (not installed yet)
docker info
none (not installed yet)
Diagnostics ID
none (not installed yet)
Additional Info
Uhm... well... I wanted to regenerate the errors for the 2 possible outcomes, but now completely different to what I got before:
IF I run powershell within cmd WITHOUT administrative privileges, instead of powershell directly from WIN+R, I can run the modified script and install everything. powershell-output.txt
But now it's stuck at "ddev start" or "ddev delete" while adding or deleting the hostname due to permission conflicts:
pasqual@DESKTOP-976TFCV:~$ ddev delete temp
OK to delete this project and its database?
temp in /home/pasqual/temp
The code and its .ddev directory will not be touched.
A database snapshot will be made before the database is deleted.
OK to delete temp? [Y/n] (yes): Y
project must be started to do the snapshot
The hostname temp.ddev.site is not currently resolvable, trying to add it to the hosts file
DDEV needs to run with administrative privileges.
You may be required to enter your password for sudo or allow escalation. DDEV is about to issue the command:
sudo.exe ddev.exe hostname temp.ddev.site 127.0.0.1
After that the UAC opens up and asking for the admin password for gsudo. After entering it, nothing happens and it's just stuck there forever.
I just ran into the same problem and am very happy, that I am not the first one. As far as I understand it, the only current workaround is to have a Windows user with admin privileges, that has WSL installed and then run the ddev installation?
I've hit this issue as well except I started with having installed (and uninstalled) Docker Desktop. I was following the "WSL2 + Docker Desktop Install Script" process but hit the permissions issue (I'm on Win 11 Home) so uninstalled to try the "WSL2 + Docker CE Inside Install Script" instead.
I reinstalled Docker Desktop, went to Settings → Resources → WSL2 Integration and unticked "Enable integration with my default WSL distro" which was still ticked from the previous install. Clicked Apply & Restart, closed and quit Docker Desktop, and Uninstalled Docker Desktop and rebooted (just in case).
I'm still hitting this issue.
Running the test from the shell I'm getting this:
PS C:\Windows\System32> wsl bash -c "test -d /mnt/wsl/docker-desktop >/dev/null 2>&1"
Windows Subsystem for Linux has no installed distributions.
Use 'wsl.exe --list --online' to list available distributions
and 'wsl.exe --install <Distro>' to install.
Distributions can also be installed by visiting the Microsoft Store:
https://aka.ms/wslstore
Error code: Wsl/Service/CreateInstance/GetDefaultDistro/WSL_E_DEFAULT_DISTRO_NOT_FOUND
My suspicion is that all that output is resulting in the if() returning a non-false state.
Commenting out the problematic code as described above does get us past that and things run through to the other wsl commands. Ever one of these threw the Windows Subsystem for Linux has no installed distributions error. Manually running these in a non-elevated Powershell works right up to the last command where we see that docker is not running.
PS C:\Users\Unifex> wsl ddev version
Could not connect to a Docker provider. Please start or install a Docker provider.
For install help go to: https://ddev.readthedocs.io/en/stable/users/install/docker-installation/
Dropping into the ubuntu shell and tailing /var/log/docker.log I see the following at the end.
failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to register "bridge" driver: unable to add return rule in DOCKER-ISOLATION-STAGE-1 chain: (iptables failed: iptables --wait -A DOCKER-ISOLATION-STAGE-1 -j RETURN: iptables v1.8.7 (nf_tables): RULE_APPEND failed (No such file or directory): rule in chain DOCKER-ISOLATION-STAGE-1
(exit status 4))
Despite this wsl -u root service docker start (from Powershell) and sudo service docker start (from the shell in Ubuntu) do not report this failure and result in a * Starting Docker: docker.
This is getting deep in the weeds though and is feeling like a rabbit trail that isn't the right way to fix things.
This is feeling like there is an early step missing in the docs that will let the wsl commands work for the Administrator user.