我在Windows上运行docker build时遇到问题
Dockerfile:
FROM node:alpine AS builder
WORKDIR /app
COPY . .
RUN npm cache clean --force
RUN npm install > npm.log 2>&1
RUN npm run build
FROM nginx:alpine
COPY --from=builder /app/dist/* /usr/share/nginx/html
命令:
docker build --no-cache --rm -t fe-app:latest .
问题:
Step 8/8 : COPY --from=builder /app/dist/* /usr/share/nginx/html
COPY failed: opengcs: copyWithTimeout: timed out (RunProcess: copy back from remotefs lstat /tmp/666137919f5d3c5661175c59a8f4f9051ed09611a5b560e7045828ec1f9c1ec7-mount/app/dist/uncommon/assets/data-test/service-staff-data/services-staff-ui-action.json)
完整控制台输出:
Sending build context to Docker daemon 4.471MB
Step 1/8 : FROM node:alpine AS builder
alpine: Pulling from library/node
bdf0201b3a05: Pull complete
26f0dbb4f100: Pull complete
9af56c7c17da: Pull complete
Digest: sha256:ca1695f514d5dc54b4812f8b9029b277f86b50e83870af47bfa4582af0ec695d
Status: Downloaded newer image for node:alpine
---> 1bdfa12c22dc
Step 2/8 : WORKDIR /app
---> Running in 75a2de3672da
Removing intermediate container 75a2de3672da
---> 53a7b85e7278
Step 3/8 : COPY . .
---> a6fbf046933b
Step 4/8 : RUN npm cache clean --force
---> Running in 16148fc51784
npm WARN using --force I sure hope you know what you are doing.
Removing intermediate container 16148fc51784
---> 1f0b1dbf0a36
Step 5/8 : RUN npm install > npm.log 2>&1
---> Running in 8ac705a53089
Removing intermediate container 8ac705a53089
---> 6ae70108adb1
Step 6/8 : RUN npm run build
---> Running in ba84c78a50bb
> [email protected] build /app
> ng build
Date: 2019-04-18T13:22:02.537Z
Hash: 3d032830d7fde6941cf7
Time: 66267ms
chunk {main} main.js, main.js.map (main) 270 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 237 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
chunk {scripts} scripts.js, scripts.js.map (scripts) 23.9 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 1.14 MB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 7.69 MB [initial] [rendered]
Removing intermediate container ba84c78a50bb
---> 487cf0c02a50
Step 7/8 : FROM nginx:alpine
alpine: Pulling from library/nginx
bdf0201b3a05: Already exists
08d74e155349: Pull complete
a9e2a0b35060: Pull complete
d9e2304ab8d0: Pull complete
Digest: sha256:61e3db30b1334b1fa0a2e71b86625188f76653565d515d5f74ecc55a8fb91ce9
Status: Downloaded newer image for nginx:alpine
---> 0be75340bd9b
Step 8/8 : COPY --from=builder /app/dist/* /usr/share/nginx/html
COPY failed: opengcs: copyWithTimeout: timed out (RunProcess: copy back from remotefs lstat /tmp/666137919f5d3c5661175c59a8f4f9051ed09611a5b560e7045828ec1f9c1ec7-mount/app/dist/uncommon/assets/data-test/service-staff-data/services-staff-ui-action.json)
我在我的本地环境上运行相同并且运行成功,但是我在服务器上有问题,当我在服务器上运行时,它生成了文件夹c:\ tmp \ 666137919f5d3c5661175c59a8f4f9051ed09611a5b560e7045828ec1f9c1ec7-mount,在我的本地环境中没有。
我希望有人给我一个提示,提前谢谢。
这不是如何解决问题的解决方案,是如何避免问题的解决方案:
首先压缩文件夹,然后只复制zip文件。
Dockerfile:
FROM node:alpine AS builder
RUN apk add zip
WORKDIR /app
COPY . .
RUN npm cache clean --force
RUN npm install > npm.log 2>&1
RUN npm run build
RUN zip -r npm.zip /app/dist
FROM nginx:alpine
WORKDIR /usr/share/nginx/html
RUN apk add unzip
COPY --from=builder /app/npm.zip /usr/share/nginx/html/
RUN unzip npm.zip