ODT (Office Deployment Tool) log reported error when installing into Windows Container (Server Core): C2R client returned failing error code, error code: 17002
FROM mcr.microsoft.com/windows/servercore:ltsc2019
WORKDIR C:/setup
COPY . .
ENTRYPOINT startup.cmd
curl.exe https://download.microsoft.com/download/2/7/A/27AF1BE6-DD20-4CB4-B154-EBAB8A7D4A7E/officedeploymenttool_12325-20288.exe --output .\
officedeploymenttool_12325-20288.exe
officedeploymenttool_12325-20288.exe /quiet /passive /extract:.
setup.exe /configure o365.xml
powershell -file test-o365.ps1
pause
<Configuration>
<Add OfficeClientEdition="64" Channel="Monthly">
<Product ID="O365ProPlusRetail">
<Language ID="en-us" />
</Product>
</Add>
<!-- <Updates Enabled="TRUE" Channel="Monthly" /> -->
<Display Level="None" AcceptEULA="TRUE" />
<Logging Level="Standard" Path="." />
<!-- <Property Name="AUTOACTIVATE" Value="1" /> -->
</Configuration>
# Write current datetime into result.xlsx to verify that Office COM component is working.
$filename = [System.Environment]::CurrentDirectory + "\result.xlsx"
$filename
if ([System.IO.File]::Exists($filename )) {
Remove-Item $filename
}
$xl=New-Object -ComObject Excel.Application
$xl.Visible=$false
$wb=$xl.WorkBooks.Add()
$ws=$wb.WorkSheets.item(1)
$ws.Cells.Item(1,1)= [System.DateTime]::Now
$wb.SaveAs($filename)
$xl.Quit()
We are already aware of 'server-side Automation of Office' issues as mentioned in article [3]. At current stage, we are evaluating the possibility on running legacy ASP.NET application in Windows container, with Office/COM inter-operation enabled.
I've been struggling with this for a while, and finally got it to work. I found the solution to the 17002 error was to run the setup.exe /configure config.xml while running the docker image interactively, and then committing that container. This worked for me on the windows:1809 image.
Full writeup
I'm copying the downloaded office files into the docker image separately, as I was having issues with getting the download to work from inside the docker file (see here). So I have the folder Office
at the same level as the docker file with the contents of setup.exe /download config.xml
. Then the docker file below builds a base image. I ran docker run -it {IMAGEID} powershell
, navigate to C:\\odtsetup and with the interactive console run setup.exe /configure config.xml
, exit the container and run
docker stop {CONTAINERID}
docker commit {CONTAINERID}`
I now have a base windows server image with docker installed, and can use it in the dockerfile for my application. If I need to update the server image or excel version I'll need to do this manually again, but I'm just thankful it's working.
DOCKERFILE
FROM mcr.microsoft.com/windows:1809
WORKDIR C:\\odtsetup
ADD https://download.microsoft.com/download/2/7/A/27AF1BE6-DD20-4CB4-B154-EBAB8A7D4A7E/officedeploymenttool_13426-20308.exe odtsetup.exe
RUN odtsetup.exe /quiet /norestart /extract:C:\\odtsetup
ADD config.xml .
ADD Office Office\\
config.xml
<Configuration>
<Add OfficeClientEdition="64" Channel="PerpetualVL2019">
<Product ID="O365ProPlusRetail">
<Language ID="MatchOS" />
<ExcludeApp ID="Access" />
<ExcludeApp ID="Groove" />
<ExcludeApp ID="Lync" />
<ExcludeApp ID="OneDrive" />
<ExcludeApp ID="OneNote" />
<ExcludeApp ID="Outlook" />
<ExcludeApp ID="PowerPoint" />
<ExcludeApp ID="Publisher" />
<ExcludeApp ID="Teams" />
<ExcludeApp ID="Word" />
</Product>
</Add>
<Updates Enabled="FALSE" />
<Display Level="None" AcceptEULA="TRUE" />
<Property Name="AUTOACTIVATE" Value="1"/>
<Property Name="FORCEAPPSHUTDOWN" Value="TRUE" />
<Remove All="TRUE">
</Remove>
</Configuration>
User contributions licensed under CC BY-SA 3.0