I'm new to using Docker and DevOps, and I'm currently working on containerizing a simple React quiz app that employs **json-server** to serve data from **data/questions.json**. I'm looking for a way to make live edits to my code—especially in the src, public, and data directories—and see those changes reflected immediately in the browser without having to rebuild the container every single time.
Here's a breakdown of my project structure:
- data
- questions.json
- public
- index.html
- src
- App.jsx
- components/
- index.js
- Dockerfile
- docker-compose.yaml
- .dockerignore
- package.json
- package-lock.json
In my Dockerfile, I set it up to copy the package.json files, install the dependencies, and start the app. Here's the relevant part of my docker-compose.yaml:
- I have two services, one for the backend and one for the frontend. Both containers should expose the necessary ports (8000 for the backend and 3000 for the frontend).
- The frontend is using a bind mount (.:/app) to ensure that changes to the local files reflect in the Docker container.
However, when I include the **volumes** line in the compose file, although Docker shows it's running, I can't access the frontend. It gives me an error saying 'This page isn't working' with an ERR_EMPTY_RESPONSE. When I remove the **volumes** line, everything runs fine, but I lose live reload.
What am I doing wrong, and how can I set it up so I can see changes live while the app runs in Docker without flipping back and forth with builds?
3 Answers
First off, what OS are you using for Docker? If you're on Windows 10, sometimes the file-sharing settings can mess things up. Make sure that your drives are shared in Docker Desktop settings. If you're not using Docker Desktop, there could be some other configuration issues. Let me know your setup, and I might be able to help you better!
As a workaround for hot-reloading, you could try using `npm run watch` in your package.json scripts instead of just `npm start`. This could help with detecting changes in a more effective way while you're in the Docker environment.
You might want to check the develop section in the Docker Compose documentation. Sometimes, the way you specify your volumes or how Docker syncs files can cause issues like the one you’re facing. Try adjusting your configuration based on the best practices mentioned there.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically