Get a free advice now!

    Pick the topic

    Developer OutsourcingWeb developingApp developingDigital MarketingeCommerce systemseEntertainment systems

    Thank you for your message. It has been sent.

    Tags

    Fast Docker on Windows in 2022

    Fast Docker on Windows in 2022

    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.

    More info:

    https://docs.docker.com/desktop/windows/wsl/

    https://docs.microsoft.com/en-us/windows/wsl/compare-versions

    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.

    http://localhost/

    Animation showing console

    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!

    Website on the left, network options on the right

    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

    Permission denied

    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:

    sudo su

    Docker is still not fast enough

    Make sure that WSL2 options are enabled.

    Docker settings window
    Docker settings window

    How to install Ubuntu on Windows?

    Open your Windows Start Menu, go to Microsoft Store and find Ubuntu 20.04 LTS.

    Ubuntu in Microsoft Store

    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.

    Folder browser with Ubuntu folder displayed

    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.

    Comments
    0 response

    Add comment

    Your email address will not be published. Required fields are marked *

    Popular news

    A game changer for WooCommerce users
    • Our Highlights

    A game changer for WooCommerce users

    March 24, 2023 by createIT
    The differences between a web app and a mobile app
    • Services
    • Technology
    • Trends

    The differences between a web app and a mobile app

    March 7, 2023 by createIT
    Webrooming and showrooming
    • Trends

    Webrooming and showrooming

    February 14, 2023 by createIT
    PHPStorm – fix long load time of a directory window
    • Dev Tips and Tricks

    PHPStorm – fix long load time of a directory window

    January 20, 2023 by createIT
    reCAPTCHA v3 – WordPress implementation
    • Dev Tips and Tricks

    reCAPTCHA v3 – WordPress implementation

    January 20, 2023 by createIT
    How to compare GIT and server files
    • Dev Tips and Tricks

    How to compare GIT and server files

    January 19, 2023 by createIT
    How to trigger a click event inside iframe?
    • Dev Tips and Tricks

    How to trigger a click event inside iframe?

    January 19, 2023 by createIT
    FOOEvents – generate a custom CSV report
    • Dev Tips and Tricks

    FOOEvents – generate a custom CSV report

    January 19, 2023 by createIT
    Headless chrome – testing webgl using playwright
    • Dev Tips and Tricks

    Headless chrome – testing webgl using playwright

    January 18, 2023 by createIT
    Preview big SQL files with PilotEdit
    • Dev Tips and Tricks

    Preview big SQL files with PilotEdit

    January 18, 2023 by createIT

    Support – Tips and Tricks
    All tips in one place, and the database keeps growing. Stay up to date and optimize your work!

    Contact us