Windows 上的 Dockerfile 复制超时问题

标签 docker dockerfile

我在 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

> uncommon@0.0.0 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 t。

希望有人给我提示,先谢谢了。

最佳答案

这不是如何解决问题的解决方案,而是如何避免问题的解决方案:

首先压缩文件夹,然后仅复制 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

关于Windows 上的 Dockerfile 复制超时问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55747845/

相关文章:

linux - 多个 docker 容器、IP 地址、VM、OSX

docker - 如何使用docker-compose挂载主机目录,运行主机时指定 "~/path/on/host",不在docker-compose文件中

java - 为什么在 docker 容器中执行命令与在 Dockerfile 中写入命令得到不同的结果?

docker - 为什么 "RUN rm/etc/nginx/conf.d/default.conf"没有成功?

Docker 构建与 Jenkins 问题

docker - Debezium Kafka Connect - 通过 Docker 从 Confluent Hub 加载插件时出错

docker - 为什么Virtualbox上的Docker无法找到我的DockerFile?

ssl - 使用加密的客户端证书连接到 docker 主机

docker - 如何在 dockerfile 中的 cd 命令之后执行 .sh 文件?

dockerfile - 如何自动回答安装提示(除了 "yes")?