【发布时间】:2021-10-21 13:37:34
【问题描述】:
我决定在容器中创建一个带有 Express 的服务器,并安装了 nodemon 来监视和重新加载我的代码修改,但是由于某种原因,当我修改我的代码时,容器上的 nodemon 没有重新加载。我该如何解决?
我的 Dockerfile:
FROM node:14-alpine
WORKDIR /usr/app
RUN npm install -g nodemon
COPY . .
EXPOSE 3000
CMD ["npm","start"]
我的 package.json:
{
"name": "prog-web-2",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/willonf/prog-web-2.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/willonf/prog-web-2/issues"
},
"homepage": "https://github.com/willonf/prog-web-2#readme",
"dependencies": {
"express": "^4.17.1"
}
}
我的 app.js:
const express = require("express")
const app = express()
app.get("/", (req, res) => {
res.end("Hello, World!")
});
app.listen(3000);
【问题讨论】:
标签: docker express dockerfile containers nodemon