1

我正在创建一个 Windows docker 容器,该容器将用于执行一些需要安装SQL Server 命令行实用程序的管理任务。我的目标是使用多阶段构建来确保最终映像中不包含 MSI/chocolatey 安装垃圾。当我执行 adocker build我得到这个错误:

Step 8/10 : COPY --from=setup ["C:\\Program Files\\Microsoft SQL Server" "C:\\Program Files\\Microsoft SQL Server"]
failed to create hash for Documents and Settings: readlink \\?\Volume{b9e10f4e-aa64-4233-a798-28aa8ac73055}\Documents and Settings: Access is denied.

是否可以通过这种方式复制文件Program Files?如何让这个工作?

这是我的 Dockerfile:

# Setup container installs chocolatey and sqlserver CLI tools
FROM microsoft/windowsservercore:latest as setup
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

RUN Invoke-WebRequest -OutFile chocoinstall.ps1 "https://chocolatey.org/install.ps1"
RUN . .\chocoinstall.ps1
RUN choco install 'sqlserver-cmdlineutils' -version '13.1' --yes

# Deploy Tools image
FROM microsoft/windowsservercore:latest
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# SQL server CLI tools
COPY --from=setup ["C:\\Program Files\\Microsoft SQL Server" "C:\\Program Files\\Microsoft SQL Server"]
RUN $env:PATH = 'C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\130\\Tools\\Binn\\;' + $env:PATH;

ENTRYPOINT ["powershell"]
4

1 回答 1

3

一个非常困难的问题。但是在 COPY 指令中添加注释“# escape=`”和“,”就可以了。

# escape=`
# Setup container installs chocolatey and sqlserver CLI tools
FROM microsoft/windowsservercore:latest as setup
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

RUN Invoke-WebRequest -OutFile chocoinstall.ps1 "https://chocolatey.org/install.ps1"
RUN . .\chocoinstall.ps1
RUN choco install 'sqlserver-cmdlineutils' -version '13.1' --yes

# Deploy Tools image
FROM microsoft/windowsservercore:latest
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# SQL server CLI tools
COPY --from=setup ["C:\\Program Files\\Microsoft SQL Server", "C:\\Program Files\\Microsoft SQL Server"]
RUN $env:PATH = 'C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\130\\Tools\\Binn\\;' + $env:PATH;

ENTRYPOINT ["powershell"]

(编辑:删除 .dockerignore 文件)

于 2017-05-02T17:15:11.747 回答