- Docker Desktop problems
- Fast Docker on Windows solution
- Ubuntu 20.04 LTS
- Docker WordPress with 50ms response
- Not only WordPress
- Troubleshooting Basic Problems
CHALLENGE: not fast Docker VM on Windows
SOLUTION: use built-in Ubuntu Linux on Windows
Docker containers provide an easy solution for app deployments and are a valuable asset during the development phase. Programmers use a local Docker setup to reproduce a real production environment. When you use the Linux Operating System, containers work fast and smoothly. This can be a different story on Windows 10 or 11.
Docker Desktop problems
If you want to use Docker on Windows, the Docker Desktop application needs to be installed. However, installation with default settings usually causes Docker no to work very fast. When refreshing your website or app in the browser, you can experience 30-60 seconds waiting time to get a response from the container. Do you have so much patience?
Fast Docker on Windows solution
Here is the ultimate solution:
Run Docker commands from the “Windows Ubuntu 20.04 LTS” window.
Explanation: Windows Subsystem for Linux (WSL) 2 introduces a significant architectural change as it is a full Linux kernel, allowing Linux containers to run natively without emulation. To get the best out of the file system performance when bind-mounting files, we recommend storing the source code in the Linux file system, rather than the Windows file system.
Ubuntu 20.04 LTS
Here is a real life example of fast docker on Windows. Let’s open the Ubuntu App on Windows and:
git clone https://github.com/kassambara/wordpress-docker-compose.git cd wordpress-docker-compose docker-compose up -d --build
In a couple of seconds, the docker container is up and running. You can see the entire process on the animated GIF.
Navigate in your browser to see the working WordPress installation.
Docker WordPress with 50ms response
Docker on Windows where commands are run from the Ubuntu App has a really good response time. Instead of using emulation, the container runs natively on Linux. A single blog post page in WordPress response (TTFB) is 50ms, which is quite a good result!
Not only WordPress
This solution for fast Docker in Windows is not only restricted to WordPress CMS. There is no difference if you’re using PHP Symfony, React Node server or Ruby on Rails – you will see the difference in performance speed.
Troubleshooting Basic Problems
Ubuntu displays an error: fatal: could not create work tree dir ‘wordpress-docker-compose’: Permission denied
Solution: make sure that you’re logged in in Ubuntu as root:
Docker is still not fast enough
Make sure that WSL2 options are enabled.
How to install Ubuntu on Windows?
Open your Windows Start Menu, go to Microsoft Store and find Ubuntu 20.04 LTS.
How can I access Ubuntu files?
You can access Ubuntu files using: \\wsl$\Ubuntu-20.04\home
The easiest way will be to “Add a network location” in “My Computer”. This way you can treat it as a separate volume / disc.
I have Windows11, how I can enable WSL2?
Originally in Windows 10, installing WSL2 required to apply a couple of steps: running different commands in PowerShell and restarting the system. In Windows11, it is a lot easier. You can just install the “Windows Subsystem for Linux Preview” from the Microsoft App Store: https://aka.ms/wslstorepage
That’s it for today’s tutorial. Be sure to follow us for other tips and guidelines – sign up for our newsletter and stay up to date.
Do you need someone to implement this solution for you? Check out our specialists for hire in the outsourcing section. Are you considering a global project and are uncertain how to proceed? See how we do it.