Closed therobyouknow closed 1 week ago
docker-desktop-data is not a distro, right? So please ensure WSL2 can't select it.
WSL itself can/should not block a distribution name, what if any user set that distro name explicitly. The issue should be solved by Docker developers.
docker-desktop-data is not a distro, right? So please ensure WSL2 can't select it.
WSL itself can/should not block a distribution name, what if any user set that distro name explicitly. The issue should be solved by Docker developers.
The distro itself should identify it as a distro -e.g. as a flag somewhere, not by just the name.
Or WSL should inspect the each item in the listing of wsl -l
to determine whether it is a distro. Inspect by looking at files inside the distro, headers etc. And not list anything that is not found to be a distro following those checks. Or list them separately under a different heading as non-distros and not make them selectable as the default.
@therobyouknow
I do agree that it is not a very user-friendly experience when docker-desktop-data
erroneously gets set as the default distribution. And this does tend to happen "automatically" for several reasons (and probably more than I can think):
Manual installation/enablement of WSL, followed by installation of Docker Desktop without first installing a default distribution.
wsl --install
where WSL is enabled, but the distribution installation fails for some reason. Then Docker Desktop is again installed without a default distribution in place, with docker-desktop-data
getting set as the default.
Things are installed and working normally with a default (working) distribution and Docker Desktop, but then the main distribution is reinstalled, or perhaps uninstalled and replaced by a different distribution. During the distribution uninstall/unregister
, docker-desktop-data
gets set as the default.
While these sound like corner-cases, I've seen this come up quite frequently in Stack Exchange questions, as well as (as you mention) issue reports here.
While WSL could solve this by hardcoding the docker-desktop
and docker-desktop-data
distributions as ones never to set as default automatically (unless explicitly requested by user wsl --set-default ...
), I agree with @Biswa96 that this would be a kind of hacky approach.
I also don't think that WSL can or should "define" a distribution as one that is bootable. It doesn't know until it attempts to run it. Non-bootable WSL distributions happen quite frequently as well, especially for those of us who are building our own. It could even be deliberate -- Perhaps a user wants a "data-only" distribution like docker-desktop-data
.
I think I'd propose a different feature that might solve this:
Distributions with a leading dot/period/.
would be "hidden", just like leading-dot filenames on Linux/Unix.
wsl -l
would not show these hidden distributions unless the --all
flag was used.
Hidden distributions would never be automatically set as default. If all "unhidden" distributions were uninstalled, then there would be no default distribution set.
Corollary of the above rule: If no distributions are currently installed, and a hidden distribution is created, that distribution would not be set as default.
If only hidden distributions exist, and a normally named (not a leading-dot) distribution is installed, then the newly installed unhidden distribution would automatically be set as default.
A hidden distribution could still be set as default manually by the user with wsl --set-default ...
(including the leading-filename of the distribution). Optional - Provide a warning that the user is setting a hidden distribution as default. Even though .docker-desktop
can be set as a distribution and does run, it's still not recommended.
Companion feature: wsl --rename <old_distro_name> <new_distro_name>
(I think this is self-explanatory)
At some point, hopefully, Docker could shift to using this new feature, and rename to .docker-desktop
and .docker-desktop-data
.
This seems to me to be a non-breaking change. Docker could even install its distributions with leading dots on older WSL versions without the "hidden" feature. They wouldn't be hidden on the older WSL versions, but they would eventually after a WSL upgrade.
Alternative that doesn't fix the issue, but it would be nice to have some more helpful error text around this situation.
If wsl
is run without a -d
/--distribution
flag, and the instance fails to boot (i.e. Create process not expected to return
), then it might be nice to provide some error help like:
The default distribution (docker-desktop-data) failed to boot.
You can set another installed distribution as default with:
wsl --set-default <distribution name>
You have the following distributions installed:
<insert results of wsl -l here>
... of course, substituting the actual failed/default distribution in place of docker-desktop-data
above, if it differs.
This is interesting issue. I think having a flag saying "This distro is not meant for interactive usage" is the best way forward.
It could be something that docker would specifically pass to wsl --import / wsl --register when they install the distro, and when an interactive distro is installed for the first time, this flag could be checked to see if the new distro should be set as default or not.
Any thoughts on that @benhillis / @craigloewen-msft ?
@OneBlue Interesting. I'm kind of surprised you'd pick a flag (which I assume would imply a registry entry?) over a naming convention (leading-dot). The hidden/leading-dot convention just seems so much more "Linuxy" ;-).
Would you list "not for interactive use" distributions with wsl -l
? Or only use it to determine if a distro should be a candidate for automatic "set as default" behavior?
Thinking about this again, a new command line argument to wsl --import / --register wouldn't be a good option, because that wouldn't be backwards compatible.
The best option I can think of would be adding a new argument to either wsl or wslconfig. Something like:
wsl --set-distro-hidden <name> <true|false>
That way tools like docker can call wsl --register / wsl --import, and then wsl --set-distro-hidden, and ignore if wsl --set-distro-hidden fails in older WSL versions.
The '.' prefix would work, but I don't like it as much because it would mean that any user that has a distro with that prefix would see this distro suddenly disappear after a package upgrade, which could be confusing.
@OneBlue
I do like your --set-distro-hidden
option better. That makes everything you could do with a leading-dot possible anyway. The --import
flag was, IMHO, too limiting. And, as you say, not backwards-compatible.
Minor suggestion: Just --set-hidden distroname
. This more closely aligns with the naming of other arguments, like --set-version
(vs. --set-distro-version
). And of course, --set-hidden distroname false
?
it would mean that any user that has a distro with that prefix would see this distro suddenly disappear after a package upgrade, which could be confusing
Agreed, I did consider this. But it seemed like such a rare-to-nonexistent corner-case, and easily explainable/recoverable, that it was acceptable to me. But regardless, I'm totally good with --set-hidden
(or --set-distro-hidden
, if you must 😉).
Just hit this; I couldn't figure out why launching from wsl.exe
was suddenly complaining about fstab
parsing failures, but they are indeed gone after replacing docker-desktop-data
as default distro. The ability to set hidden would be nice, and maybe docker desktop would even use it in their installer.
This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.
Thank you!
Version
Microsoft Windows [Version 10.0.22000.856]
WSL Version
Kernel Version
5.10.102.1
Distro Version
No response
Other Software
No response
Repro Steps
wsl -l
Expected Behavior
docker-desktop-data
to not be selected as the default distro.The default distro setting could be overlooked as a root cause by folks troubleshooting other things as to why their set up isn't working properly. Please help folks out by ensuring that wsl2 can't select something that is not a distro as the default.
Reference: https://github.com/microsoft/WSL/issues/5923#issuecomment-1215454084
In that reference above, we found that =setting the default distro to a real distro like Ubuntu resolved errors such as:
Unable to detect if server is already installed: Error: Command failed: C:\WINDOWS\System32\wsl.exe -d docker-desktop-data -e sh -c "[ -d ~/.vscode-server/bin/6d9b74a70ca9c7733b29f0456fd8195364076dda ] && printf found || ([ -f /etc/alpine-release ] && printf alpine-; uname -m)"
VS Code Server for WSL closed unexpectedly
Actual Behavior
docker-desktop-data
selected as the default distro.docker-desktop-data
is not a distro, right? So please ensure WSL2 can't select it.Diagnostic Logs
No response