多阶段Dockerfile构建无法复制COPY程序文件 - 访问被拒绝

时间:2017-05-02 16:13:45

标签: docker dockerfile docker-windows

我正在创建一个Windows docker容器,用于执行一些需要安装SQL Server Command Line Utilities的管理任务。我的目标是使用多阶段构建来确保最终图像中不包含MSI /巧克力安装。当我执行docker 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"]

1 个答案:

答案 0 :(得分:3)

一个非常难的问题。但添加评论"#escape =`"和","在COPY指令中做了伎俩。

# 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文件)