moby: Windows Container - spooler service crashes without warning

Description Print spooler stops without displaying a warning when you use powershell cmdlets like get-printer

Steps to reproduce the issue:

Tested with Windowsservercore:1709 and windowsservercore

  1. docker run -it microsoft/windowsservercore PS
  2. install-windowsfeature Print-server
  3. Set-Service spooler -StartupType Automatic
  4. Start-Service spooler
  5. Get-Service spooler
  6. Get-Printer

Describe the results you received:


PS C:\> get-printer
get-printer : The spooler service is not reachable.  Ensure the spooler service is running.
At line:1 char:1
get-printer ~~~~~~~~~~~
     CategoryInfo          : NotSpecified: (MSFT_Printer:ROOT/StandardCimv2/MSFT_Printer)
    [Get-Printer], CimException
     FullyQualifiedErrorId : HRESULT 0x800706ba,Get-Printer

Describe the results you expected:


PS C:\Windows\system32> get-printer

Name                           ComputerName    Type         DriverName                PortN
                                                                                      ame
----                           ------------    ----         ----------                -----
Microsoft XPS Document Writer                  Local        Microsoft XPS Document... PO...
Microsoft Print to PDF                         Local        Microsoft Print To PDF    PO...


Output of docker version:

PS C:\Windows\system32> docker version
Client:
 Version:       17.06.2-ee-10
 API version:   1.30
 Go version:    go1.8.7
 Git commit:    66261a0
 Built: Fri Apr 27 00:42:30 2018
 OS/Arch:       windows/amd64

Server:
 Engine:
  Version:      17.06.2-ee-10
  API version:  1.30 (minimum version 1.24)
  Go version:   go1.8.7
  Git commit:   66261a0
  Built:        Fri Apr 27 00:54:58 2018
  OS/Arch:      windows/amd64
  Experimental: false

Output of docker info:

Client:
 Version:       17.06.2-ee-10
 API version:   1.30
 Go version:    go1.8.7
 Git commit:    66261a0
 Built: Fri Apr 27 00:42:30 2018
 OS/Arch:       windows/amd64

Server:
 Engine:
  Version:      17.06.2-ee-10
  API version:  1.30 (minimum version 1.24)
  Go version:   go1.8.7
  Git commit:   66261a0
  Built:        Fri Apr 27 00:54:58 2018
  OS/Arch:      windows/amd64
  Experimental: false
PS C:\Windows\system32>
PS C:\Windows\system32> docker info
Containers: 12
 Running: 1
 Paused: 0
 Stopped: 11
Images: 3
Server Version: 17.06.2-ee-10
Storage Driver: windowsfilter
 Windows:
Logging Driver: json-file
Plugins:
 Volume: local
 Network: l2bridge l2tunnel nat null overlay transparent
 Log: awslogs etwlogs fluentd json-file logentries splunk syslog
Swarm: inactive
Default Isolation: process
Kernel Version: 10.0 16299 (16299.15.amd64fre.rs3_release.170928-1534)
Operating System: Windows Server Datacenter
OSType: windows
Architecture: x86_64
CPUs: 4
Total Memory: 16GiB
Name: Server1709
ID: POWN:PUNA:BC5K:EKRP:73XO:J4JQ:YCRT:JF3R:HEAW:STSP:Y6RB:LXX3
Docker Root Dir: C:\ProgramData\docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 60 (9 by maintainers)

Most upvoted comments

We have enabled this service within the new windows image (https://hub.docker.com/r/microsoft/windows-insider/).

I can’t believe it! Printing works on a Windows Server (1903) with process isolation. One container and no problems. Now the real software can be tested. Hope to hear from Windows Desktop as a host some time 😁

I executed - docker run -it mcr.microsoft.com/windows/servercore:ltsc2019 powershell to get the below result within the container on a Windows Server 2019;Version 1809 [OS Build 17763.134]- screen shot 2018-11-30 at 3 29 44 am

Still fail to install Print-Services.

@cwilhit @taylorb-microsoft I believe there’s an issue with accessing printing in Hyper-V isolation in general. I’m also receiving the same errors as @themultiplexer even when attempting basic printing from within a Hyper-V isolated printer on the latest Windows Server 1903.

I’ve tested using the below powershell snippet to ensure no custom code nor custom drivers would be causing any interference. This uses the pre-installed Microsoft Print to PDF printer that’s automatically availlable in Windows Server 1903.

(Replace $sourcetxtfile and $destpdffile with whatever location and file you wish)

$sourcetxtfile = 'c:\temp\test.txt'
$destPDFfile = 'c:\temp\test.pdf'
Add-Type -AssemblyName System.Drawing
$txtToPDF = New-Object System.Drawing.Printing.PrintDocument
$txtToPDF.DocumentName = $sourcetxtfile
$txtToPDF.PrinterSettings = New-Object System.Drawing.Printing.PrinterSettings
$txtToPDF.PrinterSettings.PrinterName = 'Microsoft Print to PDF'
$txtToPDF.PrinterSettings.PrintToFile = $true
$txtToPDF.PrinterSettings.PrintFileName = $destPDFfile
$txtToPDF.Print()

If this is executed under process-isolation, it does what is expected and converts the text file to pdf, but if executed under hyper-v isolation I receive the following :

Exception calling "Print" with "0" argument(s): "Settings to access printer 'Microsoft Print to PDF' are not valid."

From personal experience on non-containers, this is usually caused by either a typo in the settings or a driver issue.

But the following is also logged :

Message              : The print spooler failed to regenerate the printer driver information for driver Microsoft
                       enhanced Point and Print compatibility driver for environment Windows x64. Win32 system error
                       code 87 (0x57). This can occur after an operating system upgrade or because of data loss on the
                       hard drive.
Id                   : 370
Version              : 0
Qualifiers           :
Level                : 2
Task                 : 38
Opcode               : 12
Keywords             : -9223372036854773504
RecordId             : 36
ProviderName         : Microsoft-Windows-PrintService
ProviderId           : 747ef6fd-e535-4d16-b510-42c90f6873a1
LogName              : microsoft-windows-printservice/admin
ProcessId            : 1784
ThreadId             : 2268
MachineName          : af8750f4cfea
UserId               : S-1-5-18
TimeCreated          : 5/31/2019 3:31:30 PM
ActivityId           :
RelatedActivityId    :
ContainerLog         : microsoft-windows-printservice/admin
MatchedQueryIds      : {}
Bookmark             : System.Diagnostics.Eventing.Reader.EventBookmark
LevelDisplayName     : Error
OpcodeDisplayName    : Spooler Operation Failed
TaskDisplayName      : Verifying or regenerating a print driver package
KeywordsDisplayNames : {Print Driver, Classic Spooler Event}
Properties           : {System.Diagnostics.Eventing.Reader.EventProperty,
                       System.Diagnostics.Eventing.Reader.EventProperty,
                       System.Diagnostics.Eventing.Reader.EventProperty}

Also this :

Message              : Installing printer driver Microsoft enhanced Point and Print compatibility driver failed, error
                       code 0x490, HRESULT 0x80070057. See the event user data for context information.
Id                   : 215
Version              : 0
Qualifiers           :
Level                : 2
Task                 : 19
Opcode               : 12
Keywords             : -9223372036854775264
RecordId             : 35
ProviderName         : Microsoft-Windows-PrintService
ProviderId           : 747ef6fd-e535-4d16-b510-42c90f6873a1
LogName              : microsoft-windows-printservice/admin
ProcessId            : 1784
ThreadId             : 2268
MachineName          : af8750f4cfea
UserId               : S-1-5-18
TimeCreated          : 5/31/2019 3:31:30 PM
ActivityId           :
RelatedActivityId    :
ContainerLog         : microsoft-windows-printservice/admin
MatchedQueryIds      : {}
Bookmark             : System.Diagnostics.Eventing.Reader.EventBookmark
LevelDisplayName     : Error
OpcodeDisplayName    : Spooler Operation Failed
TaskDisplayName      : Installing a printer driver
KeywordsDisplayNames : {Printer, Printer Setup}
Properties           : {System.Diagnostics.Eventing.Reader.EventProperty,
                       System.Diagnostics.Eventing.Reader.EventProperty,
                       System.Diagnostics.Eventing.Reader.EventProperty,
                       System.Diagnostics.Eventing.Reader.EventProperty...}

@themultiplexer I repro’ed with your new test without UI and was successful in getting the “hello world” out.pdf file. Host was Windows Server, guest was mcr.microsoft.com/windows:1809, configured as our documentation suggests for running a process-isolated container.

@cwilhit Could we get clarification on what printing functions are supposed to work under Hyper-V Isolation?

The document (https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/print-spooler) suggests that we should be using Hyper-V isolated containers to get around the one container limit of process isolation.

Hyper-V Isolation
We recommend running your container with Hyper-V isolation. 
When run in this mode, you can have as many containers as you want 
running with access to the print services. You do not need to modify 
the spooler service on the host.

But as shown, even the most basic printing using the pre-installed pdf printer doesn’t work

Looping in @cwilhit (PM for the windows image)

The XPS document writer printer is already installed when I checked in the latest windows image (mcr.microsoft.com/windows:1809). I am seeing the same error codes you are, however those are being returned from the WMI wrappers around the PrinterSpooler APIs (https://docs.microsoft.com/en-us/windows/desktop/printdocs/printing-and-print-spooler-functions) - implication being that while something we should debug it may not preclude functionality.

The Windows image does not have the print server role, that is not a role we are currently planning to support. It does have the print spooler service however.

@taylorb-microsoft actually spooler and its media was removed from image on 1803.

@sujaypillai spooler works just fine as after you got it instaled. Here is how we do it:

  1. Run PowerShell script like this on host to get needed packages from SxS:
$folders = Get-ChildItem -Path C:\Windows\WinSxS -Directory | Where-Object {($_.Name -like "*print*") -or ($_.Name -like "*_microsoft-windows-p..*") -or ($_.Name -like "*_microsoft-windows-c..*")}
foreach ($folder in $folders) {
  Copy-Item -Path $folder.fullname -Destination .\redist -Recurse
}
  1. Build image using Dockerfile like this:
# Windows base image with Windows Server, Version 1803
FROM microsoft/windowsservercore:1803
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
COPY redist /redist

# Install printer spooler
RUN dism /online /Enable-Feature /FeatureName:Printing-Server-Role /All /NoRestart /Source:C:\redist\sxs; \
	Set-Service spooler -StartupType Automatic; \
	Start-Service spooler

Also see my comment about how to avoid spooler crashing: https://stackoverflow.com/questions/41565459/windows-2016-docker-container-error/50748146#50748146

Printers are available inside the windows-insider image and my program just runs fine 👍. When will combined images like: aspnet:4.7.2-windowsservercore-ltsc2019 be supported? TIA