node.jsreactjsdockernpmfswatch

fswatch error when trying to run react in a windows docker container


I'm running a unbuntu:latest docker container using Docker Toolbox on win10. I use create-react-app npm to automatically create a react app for me. when I run "npm start" I get the following error.

events.js:182
      throw er; // Unhandled 'error' event
      ^

Error: watch /frontend/public EMFILE
    at _errnoException (util.js:1026:11)
    at FSWatcher.start (fs.js:1383:19)
    at Object.fs.watch (fs.js:1409:11)
    at createFsWatchInstance (/frontend/node_modules/chokidar/lib/nodefs-handler.js:37:15)
    at setFsWatchListener (/frontend/node_modules/chokidar/lib/nodefs-handler.js:80:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (/frontend/node_modules/chokidar/lib/nodefs-handler.js:228:14)
    at FSWatcher.NodeFsHandler._handleDir (/frontend/node_modules/chokidar/lib/nodefs-handler.js:407:19)
    at FSWatcher.<anonymous> (/frontend/node_modules/chokidar/lib/nodefs-handler.js:455:19)
    at FSWatcher.<anonymous> (/frontend/node_modules/chokidar/lib/nodefs-handler.js:460:16)
    at FSReqWrap.oncomplete (fs.js:154:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frontend@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the frontend@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2017-09-19T00_53_33_776Z-debug.log

Pretty simple stuff - here's my dockerFile

FROM ubuntu:latest

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update
RUN apt-get install -y apt-utils
RUN apt-get install -y curl
#RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get install -y nodejs

# install editor
RUN apt-get install -y vim

# install tools and create frontend
RUN npm install -g create-react-app
RUN create-react-app frontend

# configure proxy (let's frontend talk to backend)
RUN sed '$i,\n"proxy": "http://localhost:3001"' frontend/package.json >> frontend/package.json.new
RUN cp frontend/package.json.new frontend/package.json

WORKDIR /frontend

# run the frontend
CMD npm start

I can build the same dockerfile on my mac and it works fine. FSWatch is some library that checks if files change - so not sure what's going on here exactly. I'm kind of stumped. Any help would be greatly appreciated.


Solution

  • Docker Toolbox does not support file system event notifications. (confirmed by Docker dev Mano Marks). Need to use "Docker for Windows" for it to work.

    Guess MSFT is making some $$ off me.