gpt4 book ai didi

docker-compose IOError : Can not access file in context

转载 作者:行者123 更新时间:2023-12-02 17:37:23 25 4
gpt4 key购买 nike

Docker build 将构建并运行镜像,但在 docker-compose 期间我收到以下错误:

    > .\docker-compose-Windows-x86_64.exe -f C:\t\tea\docker-compose.yml up
Building web
Traceback (most recent call last):
File "docker-compose", line 6, in <module>
File "compose\cli\main.py", line 71, in main
File "compose\cli\main.py", line 127, in perform_command
File "compose\cli\main.py", line 1039, in up
File "compose\cli\main.py", line 1035, in up
File "compose\project.py", line 465, in up
File "compose\service.py", line 327, in ensure_image_exists
File "compose\service.py", line 999, in build
File "site-packages\docker\api\build.py", line 149, in build
File "site-packages\docker\utils\build.py", line 15, in tar
File "site-packages\docker\utils\utils.py", line 100, in create_archive
File "tarfile.py", line 1802, in gettarinfo
FileNotFoundError: [WinError 3] The system cannot find the path specified:
'C:\\t\\tea\\src\\app\\accSettings\\account-settings-main\\components\\account-settings-catalog\\components\\account-settings-copy-catalog-main\\components\\account-settings-copy-catalog-destination\\components\\account-settings-copy-destination-table\\account-settings-copy-destination-table.component.html'
[18400] Failed to execute script docker-compose

> docker -v
Docker version 18.03.0-ce-rc1, build c160c73
> docker-compose -v
docker-compose version 1.19.0, build 9e633ef3

我在我的本地组策略编辑器中启用了 Win32 长路径,但没有任何运气解决这个问题。

如果有帮助,这里是 docker-compose.yml:
version: '3'

services:
web:
image: web
build:
context: .
dockerfile: Dockerfile

最佳答案

在某些情况下,这是 docker-compose 的一个已知问题。并且,它与 Windows 上 260 个字符的 MAX_PATH 限制有关。

摘自 Maximum Path Length Limitation 上的 Microsoft 文档

In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters.



通过阅读本文,似乎解决方案取决于您的 docker-compose 版本和 Windows 版本。以下是我找到的解决方案的摘要:

解决方案#1

升级到 docker-compose version 1.23.0或超越。 1.23.0 版本中有一个错误修复,描述为:

Fixed an issue where paths longer than 260 characters on Windows clients would cause docker-compose build to fail.



解决方案#2

启用 NTFS 长路径:
  • 按 Windows 键,输入 gpedit.msc 并按 Enter。
  • 导航到本地计算机策略 > 计算机配置 > 管理模板 > 系统 > 文件系统 > NTFS。
  • 双击启用 NTFS 长路径选项并启用它。

  • 如果您使用的 Windows 版本不提供对组策略的访问权限,则可以改为编辑注册表。
  • 按 Windows 键,键入 regedit 并按 Enter。
  • 导航到 HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy Objects\{48981759-12F2-42A6-A048-028B3973495F} Machine\System\CurrentControlSet\Policies
  • 选择 LongPathsEnabled 项,如果不存在,则将其创建为 DWORD(32 位)值。
  • 将该值设置为 1 并关闭注册表编辑器。

  • 解决方案#3

    Install docker-compose via pip .这似乎解决了其他遇到此问题的问题。

    来自 docker-compose 文档的专家:

    For alpine, the following dependency packages are needed: py-pip, python-dev, libffi-dev, openssl-dev, gcc, libc-dev, and make.

    Compose can be installed from pypi using pip. If you install using pip, we recommend that you use a virtualenv because many operating systems have python system packages that conflict with docker-compose dependencies. See the virtualenv tutorial to get started.

    pip install docker-compose

    If you are not using virtualenv,

    sudo pip install docker-compose

    pip version 6.0 or greater is required.

    关于docker-compose IOError : Can not access file in context,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49180066/

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