Docker Desktop shortcuts for docker compose CLI don’t work in WSL
Description
Hello,
recently discovered that docker desktop cli shortcuts do not work, when compose runs inside WSL.
I get the following errors:
key v: View Config → Could not open Docker Desktop Compose UI
key o: View → Could not open Docker Desktop
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
- docker compose up
- press
voro
Expected behavior
Docker Desktop UI should open
docker version
Client:
Version: 27.1.1
API version: 1.46
Go version: go1.21.12
Git commit: 6312585
Built: Tue Jul 23 19:55:52 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Desktop ()
Engine:
Version: 27.1.1
API version: 1.46 (minimum version 1.24)
Go version: go1.21.12
Git commit: cc13f95
Built: Tue Jul 23 19:57:19 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.7.19
GitCommit: 2bf793ef6dc9a18e00cb12efb64355c2c9d5eb41
runc:
Version: 1.7.19
GitCommit: v1.1.13-0-g58aa920
docker-init:
Version: 0.19.0
GitCommit: de40ad0
docker info
Client:
Version: 27.1.1
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.16.1-desktop.1
Path: /usr/local/lib/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.29.1-desktop.1
Path: /usr/local/lib/docker/cli-plugins/docker-compose
debug: Get a shell into any image or container (Docker Inc.)
Version: 0.0.34
Path: /usr/local/lib/docker/cli-plugins/docker-debug
dev: Docker Dev Environments (Docker Inc.)
Version: v0.1.2
Path: /usr/local/lib/docker/cli-plugins/docker-dev
extension: Manages Docker extensions (Docker Inc.)
Version: v0.2.25
Path: /usr/local/lib/docker/cli-plugins/docker-extension
feedback: Provide feedback, right in your terminal! (Docker Inc.)
Version: v1.0.5
Path: /usr/local/lib/docker/cli-plugins/docker-feedback
init: Creates Docker-related starter files for your project (Docker Inc.)
Version: v1.3.0
Path: /usr/local/lib/docker/cli-plugins/docker-init
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
Version: 0.6.0
Path: /usr/local/lib/docker/cli-plugins/docker-sbom
scout: Docker Scout (Docker Inc.)
Version: v1.11.0
Path: /usr/local/lib/docker/cli-plugins/docker-scout
Server:
Containers: 3
Running: 0
Paused: 0
Stopped: 3
Images: 13
Server Version: 27.1.1
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
Swarm: inactive
Runtimes: runc io.containerd.runc.v2
Default Runtime: runc
Init Binary: docker-init
containerd version: 2bf793ef6dc9a18e00cb12efb64355c2c9d5eb41
runc version: v1.1.13-0-g58aa920
init version: de40ad0
Security Options:
seccomp
Profile: unconfined
Kernel Version: 5.15.153.1-microsoft-standard-WSL2
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 7.637GiB
Name: docker-desktop
ID: 399626a5-edb5-46eb-b0eb-c7160a441f86
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Labels:
com.docker.desktop.address=unix:///var/run/docker-cli.sock
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5555
127.0.0.0/8
Live Restore Enabled: false
WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
WARNING: daemon is not using the default seccomp profile
Diagnostics ID
B97B4395-D7EC-4030-8695-D610A3F490AB/20240818131346
Additional Info
No response
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.
- Ubuntu 24.04 (Noble) - 1.1.3 ❌
- Ubuntu 24.10 (Oracular) - 1.2.1 ✅
- Debian stable (Bookworm) - 1.1.3 ❌
- Debian testing (Trixie) - 1.1.3 ❌
- Debian unstable (Sid) - 1.1.3 ❌
- Fedora 39 - 1.1.3 ❌
- Fedora 40 - 1.2.1 ✅
- Fedora 41 - 1.2.1 ✅
- openSUSE Leap 15.6 - 1.1.3 ❌
- openSUSE Tumbleweed - 1.2.1 ✅
- Rocky 9 - 1.1.3 ❌
- Arch - 1.2.1 ✅
- Kali - 1.1.3 ❌
- NixOS 24.05 - 1.2.1 ✅
✅: 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
Installing xdg-utils with wslu solved my problem
sudo apt install xdg-utils
I had to do this today on a new install of Docker Desktop with Windows 11, and WSL2 via Ubuntu 24.04.2. I got the same errors trying to use the shortcuts, and also fixed it by installing xdg-utils and wslu.