我有一个React应用程序,我将其作为多阶段构建进行了docker化。首先,它将应用程序构建到/app/build
目录,然后nginx尝试复制它以提供它。
FROM node:alpine as build
WORKDIR /app
ADD package.json /app
RUN npm install
ADD . /app
CMD ["npm", "run", "build"]
FROM nginx:alpine
COPY --from=build /app/build/ /usr/share/nginx/html
然而,当我尝试构建图像时,第二阶段似乎无法从前一阶段复制/app/build
。
$ docker build -t foo .
...
Step 8/8 : COPY --fromm=build /app/build /usr/share/nginx/html
COPY failed: stat /var/lib/docker/overlay2/cf1f4930e894ad5b1d404943fb81e45cdd06b8a39abe434a342f5f90f4a1f58f/merged/app/build: no such file or directory
有什么问题,我该如何解决?
答案 0 :(得分:2)