I'm using docker on Windows server 2016, I have created a container using the "microsoft/windowsservercore:latest" image. On this image i have installed "Print-Server" role but when I try to call "Get-Printer" cmdlet I obtain an error with the spooler service. These are the commands used to recreate the problem:
docker run -d --name testspoolererror1 microsoft/windowsservercore:latest ping -t localhost
docker exec -it testspoolererror1 powershell
Install-WindowsFeature Print-Server
Set-Service spooler -StartupType Automatic
Start-Service spooler
Get-Service spooler
Get-Printer
This is when I receive the error:
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 In the event viewer i found the error: The Print Spooler service terminated unexpectedly. It has done this 2 time(s).
Can Anyone help me to solve this problem?
The network that docker runs on (by default) is not that same network as the host.
Pinging localhost from inside the container is not doing what you think it's doing.
Learn how docker networks as step 1.