I have created the below docker-compose file in my app:
version: '3.9'
services:
MongoDB:
...
backend:
...
frontend:
stdin_open: true
tty: true
build: ./frontend
image: frontend-image
container_name: frontend-container
ports:
- 3000:3000
volumes:
- ./frontend/src:/app/src
depends_on:
- backend
volumes:
mongodbdata:
I work on windows 11 and The frontend app is a react app. I have also enabled "Use the WSL 2 based engine" option in the docker desktop settings.
The issue is after running the container, when I change something in /frontend/src/App.js I can’t see the changes applied until I stop docker-compose and run docker-compose up again.
I can see that my changes are applied in the file tab of the container in docker desktop but it seems that hot reloading doesn’t work.
More information:
- The problem is not just about the frontend. I have the same issue in the backend as well. when I change a console.log it still prints the old statement until I restart the docker-compose. I can see in the doceker files that the changes are transferred to the container files but they are not effective.
2
Answers
Adding these 3 configs fixed the hot reloading issue:
You placed the
Inside your
build
folder.Try to remove it outside or use ${PWD}: