Windows 2016: Docker container error

8

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?

windows
docker
windows-server-2016
asked on Stack Overflow Jan 10, 2017 by bdn02 • edited Jan 10, 2017 by Scott Stensland

4 Answers

2

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
answered on Stack Overflow Jun 7, 2018 by olljanat
1

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)

answered on Stack Overflow Jan 17, 2017 by Kallie-Microsoft
-1

The reason that Kallie seems to have been able to get the above steps to work is probably because it is being hosted differently. I tried the above steps via Docker on a Server 2016 box, and hit the same errors. When I tried it via Docker on Windows 10, I was able to launch the spooler successfully and run the above commands, but I couldn't install any drivers successfully which would make it actually useful. Pnputil just throws odd "No Data" errors when attempting to install any .inf's.

My guess is that it works on Windows 10 because it's using hyper-v emulation instead of the native container used when hosting Server 2016 Core on Server 2016. Another thing I noticed was that the drivers are inherited from the base machine when creating a container on Server 2016, but not on Windows 10. I assume that's fairly well-understood behavior by Docker experts, but it does seem like the inherited drivers might be causing the crash. I'm not a Windows expert either, though.

Either way, it seems like something that Microsoft will have to look into and resolve.

answered on Stack Overflow Jan 26, 2018 by user18654
-3
  • 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.

answered on Stack Overflow Jan 10, 2017 by user2105103

User contributions licensed under CC BY-SA 3.0