Open danielwagn3r opened 2 months ago
I'm also running into this issue and investigated the source code of Docker Compose for clues.
It turns out that compose
in WSL tries to link to Docker Desktop by opening internal URLs in the form docker-desktop://...
(code loc). On Linux, the call attempts to pass the URL to xdg-open
(code loc), which inside most WSL environments is unavailable by default:
$ command xdg-open
zsh: command not found: xdg-open
Once installed (e.g. with sudo apt install xdg-utils
), URLs of the form mentioned above should be recognized as targeted towards Docker Desktop:
(Opening the URL in Chrome is just for demonstration purposes. xdg-open
takes you straight to Docker Desktop in practice.)
I've installed xdg-utils
on Ubuntu WSL, the xdg-open
command is availed therefore, but I'm still experiencing the problem.
@danielwagn3r what does xdg-open
return when you invoke it with the aforementioned URL as argument?
At first a call to xdg-open docker-desktop://dashboard/apps
raised this error:
/usr/bin/xdg-open: 882: x-www-browser: not found
/usr/bin/xdg-open: 882: firefox: not found
/usr/bin/xdg-open: 882: iceweasel: not found
/usr/bin/xdg-open: 882: seamonkey: not found
/usr/bin/xdg-open: 882: mozilla: not found
/usr/bin/xdg-open: 882: epiphany: not found
/usr/bin/xdg-open: 882: konqueror: not found
/usr/bin/xdg-open: 882: chromium: not found
/usr/bin/xdg-open: 882: chromium-browser: not found
/usr/bin/xdg-open: 882: google-chrome: not found
/usr/bin/xdg-open: 882: www-browser: not found
/usr/bin/xdg-open: 882: links2: not found
/usr/bin/xdg-open: 882: elinks: not found
/usr/bin/xdg-open: 882: links: not found
/usr/bin/xdg-open: 882: lynx: not found
/usr/bin/xdg-open: 882: w3m: not found
xdg-open: no method available for opening 'docker-desktop://dashboard/apps'
So I installed wslu
package additionally, see wslu, which brings wslview
- using this as browser inside WSL then solved the issue for me.
That's a great tip, thanks!
On my distro, xdg-open
is at version 1.2.1, which turns out to be WSL-aware and cleverly passes URLs to rundll32.exe url.dll,FileProtocolHandler
(code loc).
$ XDG_UTILS_DEBUG_LEVEL=3 xdg-open 'docker-desktop://dashboard/apps'
Selected DE wsl
I learned something today.
For the anecdote, wslview
does something similar, but through powershell.exe
:
$ wslview --verbose 'docker-desktop://dashboard/apps'
[verbose] Showing verbose output.
...
+ /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command '[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; [Console]::InputEncoding = [System.Text.Encoding]::GetEncoding(437); Start "docker-desktop://dashboard/apps"'
Addendum: list of WSL Linux distributions with their current xdg-utils
version.
✅: xdg-utils
is sufficient
❌: both xdg-utils
and wslu
are required
The full list: https://repology.org/project/xdg-utils/versions
Ubuntu 24.04 Noble ships with xdg-utils
1.1.3
Description
Hello,
recently discovered that docker desktop cli shortcuts do not work, when compose runs inside WSL.
I get the following errors:
When running the same compose project, i.e. in a Windows Terminal everything works as expected and the shortcut opens the Docker Desktop UI
See https://forums.docker.com/t/docker-desktop-shortcuts-dont-work-in-wsl/143165/5 for discussion in community forum.
Reproduce
v
oro
Expected behavior
Docker Desktop UI should open
docker version
docker info
Diagnostics ID
B97B4395-D7EC-4030-8695-D610A3F490AB/20240818131346
Additional Info
No response