重新加载MEAN堆栈应用程序Docker-compose文件错误:没有这样的文件或目录

我有一个平均的堆栈应用程序运行在三个Docker容器(mongodb,express,angular)上。 我想看到angular度的应用程序的立即变化。 我试图按照这个线程,但angular度容器得到以下错误:

no such file or directory, open '/usr/src/app/package.json' 

这是我的docker-compose文件:

 version: '3' # specify docker-compose version # Define the services/containers to be run services: angular: # name of the first service build: angular-src # specify the directory of the Dockerfile command: npm start ports: - "4200:4200" # specify port forewarding - "49153:49153" volumes: - ./angular-src:/usr/src/app express: #name of the second service build: . # specify the directory of the Dockerfile ports: - "3000:3000" #specify ports forewarding links: - mongodb # link this service to the database service mongodb: # name of the third service image: mongo command: mongod --smallfiles ports: - 27017 # specify port forewarding mongo_seed: build: ./mongo_seed links: - mongodb 

和我的泊坞窗文件angular应用程序:

 # Create image based on the official Node 6 image from dockerhub FROM node:8.9.1 # Create a directory where our app will be placed RUN mkdir -p /usr/src/app # Change directory so that our commands run inside this new directory WORKDIR /usr/src/app # Copy dependency definitions COPY package.json /usr/src/app # Install dependecies RUN npm install # Get all the code needed to run the app COPY . /usr/src/app # Expose the port the app runs in EXPOSE 4200 49153 # Serve the app CMD ["npm", "start"] 

在docker-compose.yml中,用angular度服务中的volumes元素覆盖Dockerfile中的COPY命令的结果。

COPY package.json /usr/src/app

/ usr / src / app的内容:package.json

COPY . /usr/src/app

/ usr / src / app的内容:(包含在构build上下文中的任何内容),packages.json

当您docker-compose up并且angular度服务运行时,会挂载一个卷:

 volumes: - ./angular-src:/usr/src/app 

/ usr / src / app的内容:( angular-src中的所有内容)

装入卷时,不会将卷中的文件添加到容器中的文件中,而是replace批量目录。