'Unable to enable hot reload for React on docker

I'm new to docker so I'm sure I'm missing something.

I'm trying to create a container with a react app. I'm using docker on a Windows 10 machine.

This is my docker file

FROM node:latest

EXPOSE 3000

ENV PATH /app/node_modules/.bin:$PATH

# install app dependencies
COPY package.json ./
COPY package-lock.json ./
RUN npm install --silent
RUN npm install [email protected] -g --silent


COPY . /app

WORKDIR /app

CMD ["npm","run", "start"]

and this is my docker compose

version: '3.7'

services:

  sample:
    container_name: prova-react1
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - '.:/app'
      - '/app/node_modules'
    ports:
      - 3000:3000
    environment:
      - CHOKIDAR_USEPOLLING=true
      - COMPOSE_CONVERT_WINDOWS_PATHS=1

When i start the container if I go on the browser everything is working fine but when i go back to Visual Studio Code and I make a modification to the files and save nothing occurs to the container and even to the website



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source