I am using Docker with fig to create NodeJS dev-env.
As long as I use nodemon to view server.js, changing server.js will not restart the server.
CMD ["nodemon", "/nodeapp/server.js"]
But while I switched from nodemon to supervisor, then it will work!
CMD ["supervisor", "/nodeapp/server.js"]
Does anyone know where the problem is?
Further information below:
My folder structure:
app/server.js package.json node_modules/ fig.yml Dockerfile
fig.yml:
nodejs: build: . ports: - "8080:8080"
Dockerfile:
RUN apt-get update --fix-missing RUN rm /bin/sh && ln -s /bin/bash /bin/sh # NVM RUN curl -sL https://deb.nodesource.com/setup | sudo bash - && \ apt-get install -y nodejs VOLUME ./app:/nodeapp WORKDIR /nodeapp RUN rm /bin/sh && ln -s /bin/bash /bin/sh && \ npm install -g nodemon mocha supervisor CMD ["nodemon", "/nodeapp/server.js"]
Server.js: (sample code from NodeJS site)
var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello 12\n'); }).listen(8080); console.log('Server running at http://127.0.0.1:8080/');
source share