'Docker 2.3.0.4 with Devilbox on Windows 10 WSL2 is extremely slow
I have windows 10 2004, 8-core amd cpu, 12gb ram, running an existing wsl2 debian instance just fine. I can run a typical web stack php-fpm nginx mariadb redis-server with existing WSL and the performance is fine. I have been reading that wsl2 and docker is much better now and wanted to try it out.
I installed docker 2.3.0.4 with wsl2 and installed devilbox as the web stack.
I have limited the wls process to 4gb and 4 cpus using the .wslconfig file and that's all cool and works fine.
What doesn't work fine is that a simple php page (e.g. <?php echo time(); ?>
can take 15-30 seconds to show up! anything that talks to a database incurs a 90 second load time. running a stock standard empty wordpress site is out of the question. Running the same script / site / database on nginx/debian on WSL2 works perfectly.
I can't run docker desktop application after windows rebooted (it worked before I rebooted). THe icon docker installer placed on my desktop doesn't do anything when I launch it. I don't see a process turning up in task manager. Nothing seems to crash, it just doesn't work. I can right click on the docker icon in the tray and get to the dashboard that way. I generally work at the command line anyway so it's no big deal, thought I'd mention it.
the devilbox installation sets up a local web server and that all works reasonably well. i had to docker-compose up
several times to get it to pull the containers properly but then I do have terrible internet. the web interface is pretty snappy, I can launch tools like phpmyadmin and they LOAD fine. If I try to restore a 10mb database with 100 tables, it will time out and crash and burn. Restoring the same database through the shell via mysql works fine, even if my disk load goes to 90% and stays there for 5 minutes.
any virtual host web server I create performs abysmally. php pages take around 90 seconds to show up. a page with phpinfo() might take 45-90 seconds of white screen to show up.
HOW do I figure out why docker is just so bad compared to straight up linux on WSL2 on the same environment? I'm guessing it's something to do with the io bit windows task manager says the disk io is averaging 2% load.
Solution 1:[1]
I think simply that your 2004-generation processor does not support any of the virtualization features.
Docker runs a LAMP stack reasonably fast on my mediocre i5 setup.
During the past months I had some performance issues and tried various things like copying source from the regular disk (i.e. C:
a.k.a. /mnt/c/
) to inside of a WSL directory (i.e. inside of \\WSL$\UBUNTU\home\user\
) but git & PHPStorm had various hard to diagnose issues (although there was an improvement in latency - and an additional bouns the file system is actually case sensitive then - so 1:1 with server environment - otherwise it's on NTFS)
However, the biggest boost to performance was to minimize the number of mapped directories - initially I had set up so that the mariadb database would be accessible to the host machine:
mariadb:
image: mariadb:10
volumes:
- ./docker/mariadb:/shared # removed this for huge boost
Removing it made work with docker bearable.
Solution 2:[2]
I think it problem of docker volume and windows file sharing. Even though U use WSL2 it not mean U use linux file system. If you use file from windows system, for example: d:/workspace/myproject
, it sill windows file and folder, windows will read and scan them before any excute from docker.
I found the solution. It is install your project in WSL distribution. Open your linux distribution, for me it Ubuntu 18.0, you will start at /home/%USER_PATH%
, install your project here, for example: /home/mypc/workspace/myproject
You can remote your IDE to WSL, in VSCode, it support by extenstion Remote WSL. That make your project work on linux file system only, not share with windows, and much more faster
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | raveren |
Solution 2 | Kien Nguyen Ngoc |