Make WordPress Core

Opened 7 months ago

Last modified 6 hours ago

#62196 new defect (bug)

Improve documentation for using the local Docker environment on Windows

Reported by: desrosj's profile desrosj Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: needs-patch good-first-bug
Focuses: Cc:

Description

The README.md file has some basic instructions for getting the local Docker development environment up and running. Unfortunately, the instructions do not work on Windows. While it does take a bit more effort, the environment can run on Windows. These extra steps should be better documented.

Change History (4)

#1 @Clorith
7 months ago

As Windows has some particular quirks, especially when interacting with Linux images for Docker, it is generally recommended to use Windows Subsystem for Linux (WSL) if possible, or at least change the Docker engine to use Linux over Windows binaries, so ensure compatibility.

Although there are some scenarios where running in experimental mode will let the environments load as intended, experimental is obviously not a great things to expect contributors to run. I've gathered together some suggested wording that can be added alongside the instructions for setting up a local environment in our readme:

#### Windows specific instructions

For development on Windows, it is recommended to use the [Windows Subsystem for Linux (WSL)](https://learn.microsoft.com/en-us/windows/wsl/install), as this gives you access to a Linux environment, where the general recommendations and guides will work without any modifications.

You will then only need to enable the docker WSL integration, this is found under "Settings > Resources > WSL integration", and is a one time operation the first time after you install Docker.


If you wish to use Windows directly without WSL, start by installing Docker as in the previous instructions. Once the installation is completed, right click the Docker icon in your system tray, and choose the option "Switch to Linux containers...", and wait for Docker to restart. If this option is not present, or you only see "Switch to windows containers...", then you are already using the appropriate configuration, and can start your development environment. If you have other projects that rely on the Windows engine, you can easily swap back the same way.

This switch to the Linux engine is to ensure that the development environment runs the same Docker images as the environments were built with, ensuring it works across all contributor environments

#2 @poena
7 months ago

could you add any details about how you get the environment up and running successfully on Windows

I use WSL. I don't recall other steps, since I set them once and forgot.

#3 follow-up: @karthikeya01
3 months ago

I had tried setting up on my Windows machine following the instructions in README, I didn't face any issues (I have WSL 2 installed already). I tried unchecking use WSL 2 based engine to check if it can cause issue but I can't even uncheck it.

https://i.ibb.co/svz3gNLc/Screenshot-2025-03-04-212618.png

I think for latest Windows versions Docker uses WSL backend by default to setup.
https://docs.docker.com/desktop/features/wsl/#:~:text=Depending%20on%20which%20version%20of%20Windows%20you%20are%20using%2C%20Docker%20Desktop%20may%20prompt%20you%20to%20turn%20on%20WSL%202%20during%20installation.

Last edited 3 months ago by karthikeya01 (previous) (diff)

#4 in reply to: ↑ 3 @SirLouen
6 hours ago

Replying to karthikeya01:

I think for latest Windows versions Docker uses WSL backend by default to setup.

I can confirm as @karthikeya01 said that there are no issues with the basic setup both in Windows PowerShell and inside the WSL (Ubuntu in my case) shell.

Once I tried running over Hyper-V with VMWare and was a little tricky because you have to configure docker connection to access "remotely" to the VM, its well handled by docker desktop.

For nested virtualization, I have no idea on how it runs, but also seems to be possible: https://docs.docker.com/desktop/setup/vm-vdi/

Mainly I believe that instead of adding "installation notes" for each system, I think its OK as it's currently explained:

You will also need Docker installed and running on your computer. Docker is the virtualization software that powers the local development environment. Docker can be installed just like any other regular application.

As long as you can run docker in whatever shell you use, you have your npm set-up, no extra instructions are needed. Docker Desktop can be mentioned.

Instead of using choco I think the more modern aproach could be also commented with winget

winget install -e --id Docker.DockerDesktop

And for NPM, winget also installing fnm: https://nodejs.org/en/download/ (reminding to use a lesser version of NPM).

Finally, the only trouble is the file permissions part. Maybe some information could be expanded on this topic. By default, you will not be able to play around with files and folders within the working WP installation, not even with fs_method direct (it will trigger the Connection Information). This is mainly why I work directly on the WSL2 container and not over my Windows Filesystem (for Windows testing I prefer to use FlyEnv).

Note: See TracTickets for help on using tickets.