Docker shared volumes failing with React

On Win10/HyperV (not Toolbox), simple file sharing across volumes works fine, similar to this Youtube example.

However, when trying to set up volume sharing for a React dev environment, following Zach Silveira’s example to the letter, the volume sharing no longer seems to work.

c:> mkdir docker-test && cd docker-test
# CRA here

# build the container here
c:\docker-test> docker build -t test-app .

# Run docker with the volume map
c:\docker-test> docker run --rm -it -v $pwd/src:/src -p 3000:3000 test-app

# load localhost:3000
# make a change to App.js and look for change in the browser

Changes in App.js DO NOT reflect in the browser window.

I’ve heard this worked with toolbox, but there may be issues with the new Win10 HyperV Docker. What’s the secret?

try adding

VOLUME /src

to the Dockerfile. tell docker there is a mapped volume

Here’s the Dockerfile. Adding VOLUME to no avail :frowning:

FROM node

COPY package.json package.json

RUN npm install

COPY . .


VOLUME /src

CMD npm start

EXPOSE 3000

if you do docker ps, get the container id, and then docker exec container_id ls /src
is the file date/time updated?

maybe do it before and after the file is changed…

how are you reloading the npm app?

do you solve this problem?
i have same problem, looking for solution.

i think i find the reason: File system watch does not work with mounted volumes
and a possible way to fix it: https://github.com/merofeev/docker-windows-volume-watcher
i will try it tonight cause now i use mac for work.