docker - 在 docker 容器中安装 cygwin 时出错:系统找不到指定的路径。(0x3) 错误=hcsshim::ImportLayer - 在 Win32 中失败
问题描述
我有一个简单的 Dockerfile:
FROM mcr.microsoft.com/windows:1809
# Install chocolatey
RUN powershell.exe Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# Install cygwin
RUN choco install -y cygwin --version 3.1.2
RUN refreshenv
CMD [ "powershell" ]
结果是
PS C:\vagrant\delme> docker build . -t localhost/async_windows_service
Sending build context to Docker daemon 2.048kB
Step 1/5 : FROM mcr.microsoft.com/windows:1809
---> 2de0138f1799
Step 2/5 : RUN powershell.exe Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
---> Using cache
---> 7ee59b0c4334
Step 3/5 : RUN choco install -y cygwin --version 3.1.2
---> Running in e6c3d1130a4e
Chocolatey v0.10.15
Installing the following packages:
cygwin
By installing you accept licenses for the packages.
Progress: Downloading chocolatey-core.extension 1.3.5.1... 100%
Progress: Downloading Cygwin 3.1.2... 100%
chocolatey-core.extension v1.3.5.1 [Approved]
chocolatey-core.extension package files install completed. Performing other installation steps.
Installed/updated chocolatey-core extensions.
The install of chocolatey-core.extension was successful.
Software installed to 'C:\ProgramData\chocolatey\extensions\chocolatey-core'
Cygwin v3.1.2 [Approved]
cygwin package files install completed. Performing other installation steps.
Download site: http://mirrors.kernel.org/sourceware/cygwin/
Installing 64-bit Cygwin...
Cygwin has been installed.
Added C:\ProgramData\chocolatey\bin\Cygwin.exe shim pointed to 'c:\tools\cygwin\cygwin.bat'.
Copying cygwin package manager (setup) to C:\tools\cygwin
Environment Vars (like PATH) have changed. Close/reopen your shell to
see the changes (or in powershell/cmd.exe just type `refreshenv`).
ShimGen has successfully created a shim for setup-x86.exe
The install of cygwin was successful.
Software installed to 'C:\tools\cygwin'
Chocolatey installed 2/2 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
re-exec error: exit status 1: output: time="2020-06-02T22:03:52+02:00" level=error msg="hcsshim::ImportLayer - failed failed in Win32: The system cannot find the path specified. (0x3)" error="hcsshim::ImportLayer - failed failed in Win32: The system cannot find the path specified. (0x3)" importFolderPath="C:\\ProgramData\\docker\\tmp\\hcs292836507" path="\\\\?\\C:\\ProgramData\\docker\\windowsfilter\\eeae1d5f886b0b035f4466cf124056f7c1924283548cd960e0024a33d1219984"
hcsshim::ImportLayer - failed failed in Win32: The system cannot find the path specified. (0x3)
我尝试了不同版本的 cygwin,还修改了存储大小,如这里所建议的那样。
它很奇怪。安装似乎很顺利,但 docker 找不到文件(我想是一层)path="\\\\?\\C:\\ProgramData\\docker\\windowsfilter\\eeae1d5f886b0b035f4466cf124056f7c1924283548cd960e0024a33d1219984"
事实上,在我的C:\ProgramData\docker\windowsfilter
目录中,没有以 eeae1d 开头的文件夹...
请注意,只有 cygwin 会导致问题。我可以安装各种其他软件。
解决方案
Cygwin 使用的硬链接似乎没有被 Docker 正确处理。特别是当 Docker 尝试提交图像时,它会因“hcsshim::ImportLayer - 找不到路径”错误而失败。
我最近遇到了同样的问题,在我摆脱了 Cygwin 安装中的硬链接之后,我能够毫无问题地提交图像。
为了摆脱硬链接,我压缩并解压缩了 Cygwin 文件夹。
推荐阅读
- javascript - 带有复选框“已选中”属性的信息将保存在本地存储中
- glsl - 着色器中的矩形/正方形渐变
- python - 如何忽略字符串文字中的注释
- postgresql - 将 .bk 文件恢复到 postgreSQL 数据库
- python - 为什么在这种情况下 matplotlib 会线性绘制?
- c# - 如何使用 C# 从 Internet Explorer 11 启动具有特定 URL 的 Google Chrome 选项卡
- javascript - Cordova iOS 应用程序:此处地图的自定义标记图标不起作用
- typescript - 与 SQL 中的 Dexie.js(IndexedDB)复合主键?
- deep-learning - 如何在 NVIDIA Jetson Nano 上将 U-Net 分割模型转换为 TensorRT?(进程终止错误)
- android - 将 JAR 包装到 AAR 文件