我根据docker docs在我的dokcerfile中使用了multi-stage builds:
FROM node:8 as build
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn
COPY . ./
RUN REACT_APP_BACKEND_BASE_URL=http://localhost:8010 yarn build
FROM mhart/alpine-node:8
RUN yarn global add serve
WORKDIR /app
COPY —-from=build /usr/src/app/build .
#COPY ./build .
CMD serve -p 80 -s .
但出现以下错误
Step 8/9 : COPY —-from=build /usr/src/app .
COPY failed: stat /var/lib/docker/tmp/docker-builder527544225/—-from=build: no such file or directory
我也尝试使用索引而不是名称:
COPY —-from=0
,但结果仍然相同。如果我跳过第一个构建,则手动踢出 yarn 构建并将复制结果复制到单个容器中
#COPY ./build .
它工作正常...
Docker version
Client:
Version: 17.09.1-ce
API version: 1.32
Go version: go1.8.3
Git commit: 19e2cf6
Built: Thu Dec 7 22:22:25 2017
OS/Arch: darwin/amd64
Server:
Version: 17.09.1-ce
API version: 1.32 (minimum version 1.12)
Go version: go1.8.3
Git commit: 19e2cf6
Built: Thu Dec 7 22:28:28 2017
OS/Arch: linux/amd64
Experimental: true
最佳答案
Dockerfile中的破折号类型错误。您的电话:
COPY —-from=build /usr/src/app/build .
与以下内容不同:
COPY --from=build /usr/src/app/build .