简体   繁体   English

即使我使用nodemon,Docker也不会重新加载nodejs应用程序?

[英]Docker not reload nodejs app even I use nodemon?

I have a problem which it took my two days and still not find any solution. 我有一个问题,我花了两天时间,仍然找不到任何解决方案。 I am developing an express app with docker but when make code changes docker not reload the app. 我正在与Docker开发一个快速应用程序,但是当更改代码时Docker不会重新加载该应用程序。 I have to docker-compose down and up to see the changes. 我必须上下泊坞窗组成以查看更改。 I search a lot on the internet but can't find any solution to fit my problem. 我在互联网上进行了大量搜索,但是找不到适合我问题的解决方案。

I will very grateful if you help me. 如果您能帮助我,我将非常感谢。 Thanks a lot. 非常感谢。

My docker directory like this: 我的docker目录如下:

/api
   Dockerfile
/mongo
   Dockerfile
docker-compose.yml

Here is my /api/Dockerfile code 这是我的/ api / Dockerfile代码

FROM node:latest

RUN mkdir app
WORKDIR /app
COPY . /app
RUN npm install
EXPOSE 3000
CMD ["npm", "start"]

Here is my compose file 这是我的撰写文件

version: '2'
services:
  api:
    container_name: ats-express
    build: ./api
    volumes:
      - ../ats-api:/app
    ports:
      - "3000:3000"
    links:
      - mongo
    depends_on:
      - mongo

    restart: always

and here is my npm start script in package.json at express-api 这是我在express-api的package.json中的npm启动脚本

"scripts": {
    "start": "nodemon ./bin/www"
  }

This just so happened to me before, and my way of resolving this issue is to add a --legacy-watch flag to the nodemon command 这是我之前遇到的情况,解决此问题的方法是在nodemon命令中添加--legacy-watch标志

"scripts": {
    "start": "nodemon --legacy-watch ./bin/www"
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM