Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

windows 10 - docker on wsl2 very slow

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 Windows and Docker and switched on the Docker flag to use wsl2 and was hoping for some performance boost for my Oracle Database running in a Docker container but unfortunately the change slowed down the container and my laptop dramatically. The performance of the container is about 10x slower and my laptop is pretty much stuck when starting the container. It seems as if the memory consumption would completely use up my 8GB and heavy memory swapping starts to take place. Is there anything I can do to improve the performance of Docker on wsl2 or at least to better understand what's wrong in my setup?

My environment:

  • Processor Intel(R) Core(TM) i7-2620M CPU @ 2.70GHz, 2 Core(s)
  • Installed Physical Memory (RAM) 8.00 GB
  • Microsoft Windows 10 Pro Version 10.0.19041 Build 19041
  • Docker version 19.03.8, build afacb8b
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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:UsersuserName

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...