根据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
,但结果仍然相同。
如果我跳过第一次构建,我会手动踢出纱线构建,然后将构建结果复制到单个容器中
#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
答案 0 :(得分:6)
Dockerfile中的破折号类型错误。你的行:
COPY —-from=build /usr/src/app/build .
与:
不同COPY --from=build /usr/src/app/build .