I have a trivial node.js docker app.
I am able to run it successfully, however the code reloading inside the container does not work despite mounting the volume as described in the docker-compose docs.
Directory layout:
my-test-app
| docker-compose.yml
| Dockerfile
| index.js
| package.json
Dockerfile:
FROM mhart/alpine-node:8
WORKDIR /app
COPY . .
EXPOSE 5000
CMD ["node", "index.js"]
docker-compose.yml:
version: '3'
services:
node-app:
build: .
ports:
- "5000:5000"
volumes:
- .:/app
redis:
image: "redis:alpine"
index.js:
const http = require('http');
const server = http.createServer((req, res) => {
res.end("hello world");
});
server.listen(5000);
package.json:
{
"name": "my-test-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
},
"author": "",
"license": "MIT"
}
I have also tried the following with same result (app runs, not able to live reload code)
- using the official node image, instead of
alpine-node. - putting the application code under
./appfolder insidemy-test-appand updating theCOPYinsideDockerfileandvolumesinsidedocker-compose.ymlaccordingly.
node index.jsand notnodemonor any other reloader, why should the code refresh?