COPY失败:在docker-compose上没有指定源文件

问题描述 投票:0回答:1

快速API的Dockerfile就像它:

FROM node:10.15.3

MAINTAINER AshishkrGoyal <[email protected]>

#RUN mkdir -p /usr/src/app

#define working dir
WORKDIR /usr/src/app

#available package.json, package-lock.json as well
COPY package*.json ./

#install all dependencies listed in package.json
RUN npm install

#copy all the source code to working dir
COPY . .

#mapping of port to docker daemon
EXPOSE 3000

#command in the form of array
CMD ["npm", "run", "dev"]


docker-compose.yml如下所示:

#specify the docker-compose version
version: '3.0'

services:
#specify all the services 
  angular: #it is frontend service container name
    build: public #dockerfile directory
    ports:
      - "4200:4200"

  express: #it is backend service container name
    build: server #dockerfile directory
    ports:
      - "3000:3000"
    links:
      - database

  database: #it is elastc search service container name
    image: docker.elastic.co/elasticsearch/elasticsearch:7.0.0
    ports:
        - "9200:9200"

运行命令docker-compose up时出现以下错误:错误:服务'express'无法构建:COPY失败:未指定源文件

请帮我解决这个错误。

提前致谢!!

node.js docker express docker-compose dockerfile
1个回答
0
投票
#copy all the source code to working dir
COPY . .

这将复制主机的当前目录,作为图像创建过程的一部分。 docker-compose up ...是否从Express项目的根目录执行?否则,在创建映像时将找不到Express项目文件。

© www.soinside.com 2019 - 2024. All rights reserved.