简体   繁体   English

Windows 2016:Docker容器错误

[英]Windows 2016: Docker container error

I'm using docker on Windows server 2016, I have created a container using the "microsoft/windowsservercore:latest" image. 我在Windows Server 2016上使用docker,我使用“ microsoft / windowsservercore:latest”映像创建了一个容器。 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. 在此图像上,我已经安装了“打印服务器”角色,但是当我尝试调用“ Get-Printer” cmdlet时,后台打印程序服务出现错误。 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. Get-Printer:后台打印程序服务不可用。 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. 在第1行:char:1 + Get-Printer + ~~~~~~~~~~ + + CategoryInfo:未指定:(MSFT_Printer:ROOT / StandardCimv2 / MSFT_Printer)[Get-Printer],CimException + FullyQualifiedErrorId:HRESULT 0x800706ba, Get-Printer在事件查看器中,我发现错误:Print Spooler服务意外终止。 It has done this 2 time(s). 它已经完成了2次。

Can Anyone help me to solve this problem? 有人可以帮我解决这个问题吗?

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) (现在从容器内部运行Powershell)

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 ? 您在运行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? 另外,要澄清一下,当您从容器ping本地主机时,您打算做什么? Are you trying to ping your container host? 您是否要ping您的容器主机?

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 另外,如果您正在寻找有关容器联网在Windows上如何工作的背景信息,那么这里是一个不错的起点: https : //docs.microsoft.com/zh-cn/virtualization/windowscontainers/manage-containers /容器网络

--Kallie B. (Program Manager, Microsoft Networking Team) --Kallie B.(Microsoft网络团队程序经理)

Because Windows containers are sharing same kernel with host machine you cannot have spooler running on both same time. 由于Windows容器与主机共享同一内核,因此不能同时运行后台处理程序。 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

The reason that Kallie seems to have been able to get the above steps to work is probably because it is being hosted differently. Kallie似乎能够完成上述步骤的原因可能是因为托管方式不同。 I tried the above steps via Docker on a Server 2016 box, and hit the same errors. 我在Server 2016上通过Docker尝试了上述步骤,并遇到了相同的错误。 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. 当我在Windows 10上通过Docker尝试时,我能够成功启动假脱机程序并运行上述命令,但是我无法成功安装任何驱动程序,这将使其真正有用。 Pnputil just throws odd "No Data" errors when attempting to install any .inf's. 尝试安装任何.inf文件时,Pnputil只会抛出奇怪的“无数据”错误。

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. 我的猜测是它可以在Windows 10上运行,因为它使用的是Hyper-v仿真,而不是在Server 2016上托管Server 2016 Core时使用的本机容器。我注意到的另一件事是,在Windows 10上创建容器时,驱动程序是从基础计算机继承的Server 2016,但不是在Windows 10上。我认为这是Docker专家很容易理解的行为,但是似乎继承的驱动程序可能会导致崩溃。 I'm not a Windows expert either, though. 我也不是Windows专家。

Either way, it seems like something that Microsoft will have to look into and resolve. 无论哪种方式,似乎都需要Microsoft研究和解决。

  • The network that docker runs on (by default) is not that same network as the host. docker运行的网络(默认情况下)与主机所在的网络不同。

  • Pinging localhost from inside the container is not doing what you think it's doing. 从容器内部ping localhost并没有执行您认为正在执行的操作。

  • Learn how docker networks as step 1. 了解Docker网络的第一步。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM