Reactjs 服务';客户';未能生成:复制失败:stat/var/lib/docker/tmp/docker-builder271679502/package.json:没有这样的文件或目录
我正在尝试对React.js应用程序进行docker化,但每次尝试docker compose时,我都会从标题中得到错误,我不明白为什么会发生这种情况 这是我的Dockerfile:Reactjs 服务';客户';未能生成:复制失败:stat/var/lib/docker/tmp/docker-builder271679502/package.json:没有这样的文件或目录,reactjs,docker,docker-compose,Reactjs,Docker,Docker Compose,我正在尝试对React.js应用程序进行docker化,但每次尝试docker compose时,我都会从标题中得到错误,我不明白为什么会发生这种情况 这是我的Dockerfile: # get the base node image FROM node:alpine as builder RUN mkdir /app # set the working dir for container WORKDIR /app # copy the json file first COPY pa
# get the base node image
FROM node:alpine as builder
RUN mkdir /app
# set the working dir for container
WORKDIR /app
# copy the json file first
COPY package.json /app
# install npm dependencies
RUN npm install
# copy other project files
COPY . /app
# build the folder
CMD [ "npm", "run", "start" ]
这是我的写作文件
version: "3.8"
services:
client:
container_name: client
stdin_open: true
build:
context: .
dockerfile: Dockerfile.dev
ports:
- "3000:3000"
volumes:
- "/app/node_modules"
- "./:/app"
Dockerfile与
package.json
文件位于同一目录中?我建议删除卷:
,以便Docker使用映像中内置的代码和节点_模块
树,而不是主机中任意不同的代码(如果需要实时开发环境,只需使用节点)。