Hot module reloading doesn't work when server is running in Docker

1

I'm trying to get hot module loading working in my express/react project. It works well when the site is run locally. But, when the site is run using docker, hot module reloading does not work when the file is edited on the host. The file is in a volume on the docker container, and I have confirmed that changes from the host are reflected in the docker container and vice versa.

When docker-compose exec dev vim <file> is used to edit the file a rebuild is triggered. Editing and saving the file on the host machine is just not triggering an update. What could be causing this?

Project specifics

The project uses express with webpack-hot-middleware to rebuild the frontend when the code is changed, and react-hot-loader to support the updates in the browser. I'm using WebStorm for editing and running the project, and using a docker-compose configuration for the node interpreter. The host is a Windows 10 machine, and the Docker I'm using is Docker Desktop (the Hyper-V one).

lowtex

Posted 2019-05-15T17:24:28.143

Reputation: 111

see also https://www.peterbe.com/plog/how-to-create-react-app-with-docker

– lena – 2019-05-15T17:35:41.893

This probably belongs on StackOverflow, but I was redirected to this site when I went to post it there. I didn't realize I was on a different site until after I posted this. – lowtex – 2019-05-15T17:36:54.423

create-react-app uses webpack-dev-server I believe. This project is using express with webpack-hot-middleware. The react app is created and working in docker. It's just the hot module reloading that isn't working, and only in docker. – lowtex – 2019-05-15T17:39:45.963

did you enable fallback polling in the the webpack-dev-middleware setting? https://github.com/webpack-contrib/webpack-hot-middleware/issues/139

– lena – 2019-05-15T18:03:28.527

No answers