Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows 2016: Docker container error

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?

like image 645
bdn02 Avatar asked Jan 10 '17 09:01

bdn02


2 Answers

Because Windows containers are sharing same kernel with host machine you cannot have spooler running on both same time. So stop and disable spooler from host and you are able use spooler on one container on that server.

Here is fixed set of commands:

Stop-Service spooler
Set-Service spooler -StartupType Disabled

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
like image 171
olljanat Avatar answered Nov 01 '22 15:11

olljanat


I'm sorry to hear you're having this issue and I'll be glad to do what I can to help you sort it out :)

For the sake of being thorough, I tried this myself by running the following commands:

docker run -it microsoft/windowsservercore:latest powershell

(Now running powershell from within container)

Install-WindowsFeature Print-Server
Set-Service spooler -StartupType Automatic
Start-Service spooler
Get-Service spooler
Get-Printer

I was able to run these on my system, without an error. So that's a start.

Now, from your error it looks like the spooler service didn't even start. What do you see when you run Get-Service spooler? Will you try running these commands on your system just as I have listed them above then report back with your results?

Also, to clarify, what are you trying to do when you're pinging localhost from the container? Are you trying to ping your container host?

And as a side note, if you're looking for background info on how container networking works on Windows, here's a good place to start: https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-networking

--Kallie B. (Program Manager, Microsoft Networking Team)

like image 30
Kallie-Microsoft Avatar answered Nov 01 '22 15:11

Kallie-Microsoft