这个非常简单的多阶段构建随机失败(十分之九)并显示以下消息:
Step 13/14 : COPY --from=builder /ng-app/target/www .
ERROR: Service 'web' failed to build: COPY failed: stat /var/lib/docker/overlay2/715082a9428418b33c27286a12e89539ef6580392eeb015d509c0f77fee1d8a2/merged/ng-app/target/www: no such file or directory
Dockerfile:
### STAGE 1: Build ###
# We label our stage as 'builder'
FROM node:8-alpine as builder
RUN apk update && apk add --no-cache python libnotify git openssh
COPY .yo-rc.json package.json yarn.lock bower.json gulpfile.js /
COPY src/ /src
COPY gulp/ /gulp
RUN npm set progress=false && npm config set depth 0 && yarn cache clean --force
## Storing node modules on a separate layer will prevent unnecessary npm installs at each build
## Build the angular app in production mode and store the artifacts in dist folder
RUN yarn install --no-progress && mkdir /ng-app && cp -R ./node_modules /ng-app
COPY . .
### STAGE 2: Setup ###
FROM nginx:stable-alpine
WORKDIR /usr/share/nginx/html
## Copy our default nginx config
COPY docker/httpd/nginx.conf /etc/nginx/conf.d/default.conf
## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
## From 'builder' stage copy over the artifacts in dist folder to default nginx public folder
COPY --from=builder /ng-app/target/www .
CMD ["nginx", "-g", "daemon off;"]
Docker版本是:Docker version 18.06.1-ce, build e68fc7a
内核:4.15.0-33-generic
操作系统:Ubuntu 18.04.1 LTS