gpt4 book ai didi

对于嵌套的忽略文件,Docker 构建有时会在 "file not found or excluded by .dockerignore"上失败

转载 作者:行者123 更新时间:2023-12-04 09:24:08 26 4
gpt4 key购买 nike

我的目录结构:

├── src/
├───── backend/
├─────── Dockerfile
├─────── ...
├───── frontend/
├─────── Dockerfile
├─────── node_modules/
├─────── ...
├───── commons/
├─────── ...
├── .dockerignore
.dockerignore包括行 **/node_modules由于 commons 的使用,我的构建上下文是根目录.

我两个都跑
docker build ... -f src/backend/Dockerfile . docker build ... -f src/frontend/Dockerfile .
并行,有时 backend构建将因以下特定错误而失败:

error checking context: 'file ('/workspace/src/frontend/node_modules/.staging/wrap-ansi-2a6f888f') not found or excluded by .dockerignore'.



根据我的理解(见 Why do Node modules go into .staging folder?) .staging文件夹是临时的,走它时可能会出现竞争条件(请参阅 Docker cli source)。

但是,如果 node_modules,为什么这个文件会排在第一位?被忽略?我是在滥用忽略上下文功能还是实际的竞争条件?

该问题在 Google Cloud Build 环境中重现,其中我通过图像使用 docker cli gcr.io/cloud-builders/docker , 使用 docker 客户端版本 19.03.5并使用 docker 服务器版本 18.09.3 运行, API 版本 1.39 .

最佳答案

免责声明:我不是 Node.js 开发人员
运行 npm install将所需的节点模块临时下载到 .staging文件夹,所以他们可以安装。正如我从您的帖子中了解到的,node_modules被忽略,包括其子文件夹。这意味着 .staging无法再访问文件夹。
您可能需要注意的另一个问题(来自官方 Docker 文档):

Do not use your root directory as the PATH for your build context,as it causes the build to transfer the entire contents of your harddrive to the Docker daemon.


这可能会导致构建冲突

关于对于嵌套的忽略文件,Docker 构建有时会在 "file not found or excluded by .dockerignore"上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59981100/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com