我正在docker容器中运行node.js应用程序,并且nodemon不会在更改时重新加载。这是我的dockerfile:
WORKDIR /app
COPY package*.json ./
RUN yarn install
COPY . /app
EXPOSE 8080
CMD ["yarn", "dev"]
我正在使用此命令构建图像:
docker image build -t test7 .
然后使用:]运行它
docker run -it -v "$(pwd)/app:/app/target_dir" test7 bash
我在容器内进行yarn dev,它将启动服务器一次,但不会重新加载。
这里是package.json文件:
"name": "self-learning", "version": "1.0.0", "main": "index.js", "license": "MIT", "scripts": { "start": "node index.js", "dev": "nodemon --legacy-watch index.js" }, "dependencies": { "cors": "^2.8.5", "express": "^4.17.1", "express-winston": "^4.0.3", "multer": "^1.4.2", "nodemon": "^2.0.2", "pg": "^7.18.2", "winston": "^3.2.1" } }
有什么解决方法吗?如何在不重建容器的情况下看到更改?
我正在docker容器中运行node.js应用程序,并且nodemon不会在更改时重新加载。这是我的dockerfile:WORKDIR / app COPY package * .json ./ RUN yarn install COPY。 / app EXPOSE ...
我想你已经这样跑了>
docker run -it -v "$(pwd)/app:/app" test7