for-win icon indicating copy to clipboard operation
for-win copied to clipboard

Docker Desktop Steals Focus constantly

Open glassleon opened this issue 2 years ago • 11 comments

Description

When I start the Docker desktop application I cannot easily use any other application as focus is constantly taken away from any other window I try to use.

Reproduce

Start Docker desktop then try to use any other application. I was trying to follow the getting started tutorial & dropping back to VSCode to edit but no sooner than I click to type the focus is taken away from the VS Code.

Expected behavior

The computer should function normally.

docker version

Client:
 Cloud integration: v1.0.33
 Version:           24.0.2
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        cb74dfc
 Built:             Thu May 25 21:53:15 2023
 OS/Arch:           windows/amd64
 Context:           default

Server: Docker Desktop 4.20.1 (110738)
 Engine:
  Version:          24.0.2
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.4
  Git commit:       659604f
  Built:            Thu May 25 21:52:17 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Version:    24.0.2
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.10.5
    Path:     C:\Program Files\Docker\cli-plugins\docker-buildx.exe
  compose: Docker Compose (Docker Inc.)
    Version:  v2.18.1
    Path:     C:\Program Files\Docker\cli-plugins\docker-compose.exe
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-dev.exe
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.19
    Path:     C:\Program Files\Docker\cli-plugins\docker-extension.exe
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v0.1.0-beta.4
    Path:     C:\Program Files\Docker\cli-plugins\docker-init.exe
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-sbom.exe
  scan: Docker Scan (Docker Inc.)
    Version:  v0.26.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-scan.exe
  scout: Command line tool for Docker Scout (Docker Inc.)
    Version:  v0.12.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-scout.exe

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 1
 Server Version: 24.0.2
 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 logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3dce8eb055cbb6872793272b4f20ed16117344f8
 runc version: v1.1.7-0-g860f061
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
 Kernel Version: 5.15.90.1-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 31.29GiB
 Name: docker-desktop
 ID: 1a4b4e77-59a3-4ada-b7a0-87f5fa54801a
 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
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

Diagnostics ID

188F7726-557D-49A7-858C-F3AC2CB236C9/20230630125014

Additional Info

This is actually quite bad & makes the machine quite unusable. I cannot even move the Docker Window as it will lose focus half way through a drag & return to where it was. I should also point out that I am on some kind of virtual machine here provided by work. That runs through Citrix.

glassleon avatar Jun 30 '23 12:06 glassleon

This behaviour is happening just with Docker Desktop 4.20.1 or also with previous versions? Any way you can record a video and show the issue?

bsousaa avatar Jul 03 '23 15:07 bsousaa

This behaviour is happening just with Docker Desktop 4.20.1 or also with previous versions? Any way you can record a video and show the issue?

I have looked into this & I am convinced that my Windows OS is below the build number required. https://github.com/microsoft/wslg/wiki/Diagnosing-%22cannot-open-display%22-type-issues-with-WSLg#verify-you-are-running-on-windows-build-21364

Running ver on a cli yields: Microsoft Windows [Version 10.0.19045.3086] where the above link states I require 21364 as a build number. I have raised an internal request to upgrade that if possible. Thank you for taking the time to respond but I think I have a way forward here.

glassleon avatar Jul 05 '23 08:07 glassleon

Closing the issue for now. Feel free to comment and will re-open if needed.

bsousaa avatar Jul 05 '23 09:07 bsousaa

Sorry for replying on a closed thread, but I decided to record this for posterity as I encountered the same issue and it took me a while to figure it out.

What worked for me was to disable WSLg on my machine as per these instructions. https://x410.dev/cookbook/wsl/disabling-wslg-or-using-it-together-with-x410, steps are reproduced below:

Step 1 Create a .wslconfig file in your Windows home folder, open your Windows home folder by entering %USERPROFILE% in Windows File Explorer.

Step 2 Add the following two lines to .wslconfig

[wsl2]
guiApplications=false

Step 3 Shutdown WSL, You can shutdown WSL by entering the following command from PowerShell or Windows Command Prompt:

wsl --shutdown

I used this command-line tool to figure out what was taking focus constantly https://superuser.com/a/1749750 And it turned out to be C:\Windows\System32\mstsc.exe which got me on the right track.

After disabling WSLg and restarting wsl, focus is not stolen anymore.

sverrirs-advania avatar Aug 22 '23 15:08 sverrirs-advania

Sorry for replying on a closed thread, but I decided to record this for posterity as I encountered the same issue and it took me a while to figure it out.

What worked for me was to disable WSLg on my machine as per these instructions. https://x410.dev/cookbook/wsl/disabling-wslg-or-using-it-together-with-x410/%20asdf%20sadf%20asd%20asdfsd%20f

I used this command-line tool to figure out what was taking focus constantly https://superuser.com/a/1749750 And it turned out to be C:\Windows\System32\mstsc.exe which got me on the right track.

After disabling WSLg and restarting wsl, focus is not stolen anymore.

It works for me. Thanks so much as it's a realy annoying issue.

kaisxu avatar Aug 31 '23 03:08 kaisxu

I encounter the same issue on MacOs, have been ignoring it for some time now. It always happens as far as I can remember. I'm on MacOs Sonoma now version Version 4.25.0 (126437)

I would very much like to refrain from twiddling and tweaking system settings en just have docker start up without hogging the focus away from where i'm currently working on.

melcarthus avatar Nov 12 '23 13:11 melcarthus

Words cannot express how much this has helped me.

Many many times, this problem would start up in the middle of coding and drive me nuts. The config update did the trick.

Opened explorer, navigated to %USERPROFILE%. I created a file named .wslconfig and added the following:

[wsl2] guiApplications=false

Save, then open a command prompt and run the following: wsl --shutdown

Start docker back up and the problem is gone.

I added the steps here because some of the links in the answer post were broken.

I encounter the same issue on MacOs, have been ignoring it for some time now. It always happens as far as I can remember. I'm on MacOs Sonoma now version Version 4.25.0 (126437)

I would very much like to refrain from twiddling and tweaking system settings en just have docker start up without hogging the focus away from where i'm currently working on.

I'm experiencing an issue with Docker Desktop (version 4.32.0, 157355) on macOS Sonoma (15.1 24B83). The application is repeatedly taking focus, even when minimized. Is there a known workaround for this behavior?

siprikorea avatar Oct 31 '24 05:10 siprikorea

met the same with couple version, and remains even i update to latest did a blind guess and "sign in" ( if the 'steal focus' was intend to prompt me to sign in seems reduced, but still a very weird way ( and didn't found such on my cooreate laptop

see if this helps in some sort, or we can find the logic piece in code ( if that's public

aratic avatar Jan 10 '25 02:01 aratic

Docker stealing focus every 10 seconds has started again ...

Is basically impossible to do any development work. :(

Current solution is to close the Docker Desktop window while making changes and reopen every time I need to check it.

MacOS 15.3.1 (24D70) Docker Desktop v4.39.0

sgamble1-wowcorp avatar Mar 06 '25 23:03 sgamble1-wowcorp

I had it installed for several months, had no such problem. Reinstalled Windows few days back and reinstalled Docker, now I have this stealing focus issue. I don't understand it at all. It steals focus whenever it launches. Will update if the fix mentioned a few posts above worked or not.

UPDATE: OK I can confirm the fix is working. I don't know if it's because earlier I had "[wsl2] guiApplications=false" or not, or if I had some WSL components still running in the background despite running the wsl --shutdown command multiple times. But I closed everything related to wsl manually (using Process Lasso) and then change the wsl2 line to 2 separate lines, and since then it's working.

BattouSaeen avatar Mar 24 '25 17:03 BattouSaeen

Although this was a problem very specific to me, just noting it here in case someone runs into a similar issue. For context, I'm on a Mac (Sequoia 15.5).

I was running an emulator for GCP spanner that relies on Docker running and having a specific ports open for the container (9010 and 9020). Every time I start the emulator, I had a script that would kill any process running on those ports. However, I had recently installed a totally unrelated application (Logitech GHUB for my mouse) that apparently utilizes those same ports.

When my script ran, it would kill the connection to those ports for Logitech, the emulator would immediately listen on those ports, and Logitech would then fail to reconnect to those ports and would seemingly retry every few seconds. This constant retrying was causing it so nothing on my computer would retain focus like everyone above is experiencing.

All in all if you're having issues, try to see if any of the containers you're running are utilizing ports that might be used by another application. A command for mac you can use: sudo lsof -i -n -P | grep TCP.

kanehjeong avatar Jun 05 '25 06:06 kanehjeong