How to setup dev containers in windows
Adele Beitvashahi

Adele Beitvashahi @adelbeit

About: I like to build stuff. Looking for work 👀 My posts serve as documentation for future me for problems that I encounter and can't find good resources on.

Joined:
Nov 4, 2022

How to setup dev containers in windows

Publish Date: Aug 28 '24
6 1

If you are going to work with dev containers in Windows you need to realize that they will break HMR (hot module reload) and increase build time unless you put your code inside WSL instead of the windows filesystem.

How Dev Containers Work in Windows

Dev containers use Docker, which relies on WSL. When you spin up a dev container, VSCode starts a docker container in WSL, and mounts the files from windows (if they are stored there). This means changes have to cross the WSL-Windows environment. This tends to break HMR, because HMR relies on file change API of the host env, and the filesystem events don't travel well between different host environments.

code stored in Windows vs WSL

Correct setup for dev containers in Windows

1. Dev container setup in WSL

2. Clone repo inside the WSL filesystem

Now you should be able to do yarn && yarn dev inside WSL and HMR should work.

Comments 1 total

  • Kody
    KodyDec 12, 2024

    I appreciate the graphic. Very effective for getting the big picture here thank you.

Add comment