docker on wsl2 very slow

后端 未结 6 1911
离开以前
离开以前 2021-01-01 17:13

After having read about the performance improvements when running Docker on wsl2, I have been waiting for the official release of Windows 10 that supports wsl2. I updated Wi

相关标签:
6条回答
  • 2021-01-01 18:02

    This comes from the "vmmem" which consumes as much resource as it can. To solve the problem just go to your user file for me in

    C:\Users\userName

    In this directory create a file named ".wslconfig" in which you will configure how many resources can consume WSL2:

    [wsl2] 
    memory=900MB    #Limits VM memory in WSL 2 to 900MB 
    processors=1    #Makes the WSL 2 VM use one virtual processors
    

    Now close your docker and wait for "vmmem" to close in the task manager.

    then You can restart docker and normally "vmmem" will not exceed the limit you have set (here 900MB) If don't work restart your computer.

    I hope it helped you.

    0 讨论(0)
  • 2021-01-01 18:02

    You can edit setting docker return Hyper-V. Click docker -> Setting -> Uncheck "Use the WSL 2 based engine".

    0 讨论(0)
  • 2021-01-01 18:03

    Maybe you could try to disabling IPv6 in the docker daemon config.json. You can edit it via the Docker Desktop, under Settings > Docker Engine.

    0 讨论(0)
  • 2021-01-01 18:04

    wsl container have they proper filesystem isolated from the windows filesystem. The base idea is to copy your source code from windows file systeme to wsl file systeme.

    from window you can acces the wsl container and copy your project to a wslcontainer :

    navigate with explorer to \\wsl$

    rebuild the container from this location this will do the trick !

    0 讨论(0)
  • 2021-01-01 18:05

    Probably you have your code on the Windoes machine like in

    C:\\Users\YourName\projects\blahfu
    

    But you're using docker on WSL 2 which is then on another filesystem. So if you do a docker build you got all the code/context copied from Windowsfilesystem to Linux filesystem and then from there to the docker container. This takes it's most of hte time and is incredibly slow.

    Try to put your project into

    /home/YouName/projects/blahfu
    

    This should give quite a performance boost.

    0 讨论(0)
  • 2021-01-01 18:05

    If the data for the actual docker container is stored on a windows file system (i.e. NTFS) instead of stored on a native linux filesystem (regardless of what the docker container contents are, which are likely already linux based), then I think you are going to see slow performance because you're running WSL and using the docker container from a mounted WINDOWS file system (i.e. /c/mnt/...).

    If you copy your docker container to something like /usr/local, or /home//docker on WSL then you may see a 10x performance INCREASE. Try that and see if it works?

    0 讨论(0)
提交回复
热议问题