Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running gui docker container (based on ubuntu) in Windows Docker Desktop is extremely lagging

i have a docker container based on ubuntu:20.04 with running qtcreator. I tested this container in Ubuntu host machine and its work perfectly and fast.

But with windows docker desktop there is extremely lagging.. for XServer i use VcSrv from https://sourceforge.net/projects/vcxsrv/.

Actually, any gui docker app works same way (i tried xeyes and firefox apps, they are lagging too approximately the same - the program window does not keep up with the user's actions: resize window, scroll, typing, etc) gif with lagging

to fix this problem i tried:

  1. with and without wsl2 based engine wsl2 based engine

  2. wsl integration (and without it) wsl integration

  3. create .wslconfig with maximum resource priority to wsl

  4. disable hyper-v

nothing works.

Maybe I don't understand something and this issue is somehow very easily solved. Please tell me how to significantly speed up the response of such an application running in a linux container on a windows host machine

like image 406
Vavp Avatar asked Sep 19 '25 13:09

Vavp


1 Answers

I had a very similar problem to you as well. I had a GUI app that when ran on host Linux machine it worked fine and was fast. But when ran inside docker container it was laggy. After looking into it I realized that docker containers don't by default have access to GPUs so after giving it access to my nvidia GPU it was smooth like on host machine. Here is how I did it.

First make sure I installed nvidia runtime for docker with these commands:

distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker

After this I already had a config file in this location

/etc/docker/daemon.json

And it looked like this:

{
  "runtimes": {
    "nvidia": {
      "path": "nvidia-container-runtime",
      "runtimeArgs": []
    }
  },
  "default-runtime": "nvidia"
}

I run mine with docker compose so I just added this to my GUI service and it worked as expected:

deploy:
      resources:
        reservations:
          devices:
            - capabilities: [gpu]
    runtime: nvidia
    environment:
      - DISPLAY=${DISPLAY}
      - NVIDIA_VISIBLE_DEVICES=all
      - NVIDIA_DRIVER_CAPABILITIES=all

To reacp... I had a GUI application on my host Linux Ubuntu 22.04 machine that worked perfectly fine and when running it inside my Ubuntu 22.04 container it was laggy and not as responsive like it was on host. After following the steps above it worked.

like image 53
baileyhelfer Avatar answered Sep 22 '25 10:09

baileyhelfer