'Hot Reloading Page in React 17.0.2 within a container doesn't work
If I run locally run start
Everything works perfectly.
After executing the command docker run -p 3000:3000 -v /app/node_modules -v ${pwd}:/app b88c46febae5
I get an unresponsive server which is just stuck. I cannot terminate it by pressing CTRL + C
What I did....
Created .env file in a root project and inserted (in any order, separately, together, with a command npm start, etc.) None of the above worked for me.
FAST_REFRESH=false
CHOKIDAR_USEPOLLING=true
package.json
"react": "^17.0.2",
"react-scripts": "5.0.0"
If I enter into a running container and watch those changes in the file I edited in my IDE - they've been applied.
Windows 10 with WSL 2
Here's a brief video https://sendvid.com/y0qbl7bl
Solution 1:[1]
It just happened to me and I solved it by disabling the wsl2 backend in Docker (Settings > Resources > Disable that checkbox). Now I'm using Hyper V instead, and it works (though Docker UI says it is legacy).
Btw, when I converted Docker Desktop to use wls2 as the backend, it seemed to have deleted all my images, but once I converted it back they were there.
Another possible solution, mentioned in the question's comments, is moving the project folder to a location inside the Linux WSL2 filesystem. If my "legacy" solution eventually stop working, it will be the next thing I'll try.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | marcelocra |