我有一个在三个 Docker 容器(MongoDB、Express、Angular)上运行的 MEAN 堆栈应用程序。我希望看到对 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 应用程序的 docker 文件:
# 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"]