File watching in windows with docker (Parcel 2)
See original GitHub issue🐛 bug report
I am trying to get a parcel app running in docker
on a Windows host, so far I can build the app, but file watching does not work and a rebuild is not triggered when editing files.
Related Issues: #564, #1308, #2539.
🎛 Configuration (.babelrc, package.json, cli command)
docker-compose.yml
:
version: '3'
services:
web:
build: .
command: npm run start
volumes:
- .:/usr/app/
- /usr/app/node_modules
ports:
- "1234:1234"
- "1235:1235"
environment:
- CHOKIDAR_USEPOLLING=1
Dockerfile
:
FROM node:latest
WORKDIR /usr/app
COPY package.json .
RUN npm install --quiet
COPY . .
Start script: NODE_ENV=development parcel src/index.html --hmr-port 1235
.
🤔 Expected Behavior
When a file is modified a rebuild will trigger.
😯 Current Behavior
Project builds initially, but does not rebuild.
💁 Possible Solution
Have tried the mentioned fixes in the above linked issues, these include adding CHOKIDAR_USEPOLLING=1
to the docker
container, and trying to bind the HMR
port on the container and the Windows host.
🔦 Context
Wanting to speed up development with hot reloading.
💻 Code Sample
As above, can include a dummy repo if needed.
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | ^2.0.0-alpha.3.2 |
Node | 13.3.0 |
npm/Yarn | 6.13.1 |
Operating System | Windows 10 |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
File system watch does not work with mounted volumes
I can confirm that docker-volume-watcher (github) works perfectly on Windows 10 (Docker Toolbox w/ VirtualBox) with an alpine docker ...
Read more >docker-windows-volume-watcher 1.2.0
A tool to notify Docker contianers about changes in mounts on Windows. ... The script uses watchdog package to observe file change events...
Read more >Persist data in a container app using volumes in VS Code
Remove any getting-started containers. · In the app folder, run the following command. Bash Copy · You can watch the logs using docker...
Read more >docker-windows-detect-changes
An API server is started within the Docker container · A file watcher is started in the Windows powershell. · The file watcher...
Read more >How to containerize Python applications with Docker - YouTube
We look at two different projects and build Docker Containers for a Python script and for a web application using Flask.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@DeMoorJasper I am having a perhaps related issue on: Win10 using Docker and WSL2, via VSCode’s .devcontainer workflow.
It seems that mounted host directories via WSL2 do not trigger the docker’s INotify, which means that file watchers like parcel don’t notice when a change occurs. NOTE: I only tested this on docker, not via the stand-alone WSL2 subsystem). I saw some passing mentions that docker mounts via WSL2 don’t trigger INotify, but nothing explicit.
I tested this by trying the basic parcel tutorial via a mounted folder (changes didn’t rebuild) and then
rsync
to a normal folder inside the docker image and trying. (which worked: changes did rebuild).I tried working around the issue by rsyncing and then using
unison
to keep everything in sync but man that is a lot of plumbing. I am giving up on this (docker devcontainers), but perhaps a solution would be to allow running Parcel in a watch mode that checks timestamps?Hey @DeMoorJasper,
I’m not really sure that it is, because if I edit a file on the host (Windows), then go into the container (
docker-compose exec web bash
) and then touch the file (touch src/components/side-menu/index.js
) the re build triggers, then if I refresh my browser the component it is updated as expected.So as far as I can tell the volumes are mounting correctly and edits are flowing through to the container, it really is a matter of the file watcher not working? And even when the re-build is trigger the browser is not updated, I am not sure what this would be related to.
Cheers.