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.

    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.

    Comments
    0 response

    Add comment

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

    Popular news

    eCommerce growth – is your business ready?
    • Services
    • Trends

    eCommerce growth – is your business ready?

    April 8, 2024 by createIT
    Digital marketing without third-party cookies – new rules
    • Technology
    • Trends

    Digital marketing without third-party cookies – new rules

    February 21, 2024 by createIT
    eCommerce healthcheck
    • Services
    • Trends

    eCommerce healthcheck

    January 24, 2024 by createIT
    Live Visitor Count in WooCommerce with SSE
    • Dev Tips and Tricks

    Live Visitor Count in WooCommerce with SSE

    December 12, 2023 by createIT
    Calculate shipping costs programmatically in WooCommerce
    • Dev Tips and Tricks

    Calculate shipping costs programmatically in WooCommerce

    December 11, 2023 by createIT
    Designing a cookie consent modal certified by TCF IAB
    • Dev Tips and Tricks

    Designing a cookie consent modal certified by TCF IAB

    December 7, 2023 by createIT
    Understanding the IAB’s Global Vendor List (GVL)
    • Dev Tips and Tricks

    Understanding the IAB’s Global Vendor List (GVL)

    December 6, 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