簡體   English   中英

Docker中的Windows Server Core,防火牆

[英]Windows Server Core in Docker, Firewall

目前,我正在一個項目中,我必須對應該在Windows上運行的應用程序進行泊塢處理。 它是可以通過命令行安裝和配置的應用程序。 該問題最終適用於任何應用程序。

我選擇的平台顯然是Windows。 因此,我選擇了一個基礎圖像mcr.microsoft.com/windows/servercore:1803作為開始。

安裝后,我的應用程序需要將規則添加到防火牆。 因此,我決定測試我是否能夠操縱容器內的防火牆。 結果是一個非常成問題的經歷。

到目前為止我所做的。

FROM mcr.microsoft.com/windows/servercore:1803

# Add user 
RUN net user /add MyUser
RUN net user MyUser ABCdef123!
RUN net localgroup "Administrators" MyUser /add

之后,我通過調用Get-NetFirewallRule測試了是否可以看到FW規則。 Tis導致錯誤:

Get-NetFirewallRule : There are no more endpoints available from the endpoint mapper.
At line:1 char:1
+ Get-NetFirewallRule
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (MSFT_NetFirewallRule:root/standardcimv2/MSFT_NetFirewallRule) [Get-NetFirewallRule], CimException
    + FullyQualifiedErrorId : Windows System Error 1753,Get-NetFirewallRule

我通過調用Get-Service檢查了當前運行的服務,該服務導致包含以下內容的服務列表: Stopped mpssvc Windows Defender Firewall 看起來FW甚至還沒有啟動。 我決定更深入地研究並檢查注冊表中的一些線索。 調用此cmd REG QUERY HKLM\\SYSTEM\\CurrentControlSet\\services\\MpsSvc /v Start我得到的值為4(已禁用)。 所以我嘗試啟用它,將其設置為2,但是在以下情況下啟動服務沒有運氣:

REG ADD HKLM\SYSTEM\CurrentControlSet\services\MpsSvc /v Start /t REG_DWORD /d 2 /f
net start MpsSvc

結果:

System error 1058 has occurred.
The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.

依賴於FW服務的運行正常(BFE,RDC等)它不會啟動。

有什么聰明的主意嗎? 提前致謝!

假設您使用的是Windows Server容器,而不是Hyper-V容器,則您擁有共享的內核,因此請使用主機的防火牆。

來自網絡隔離和安全性

根據所使用的容器和網絡驅動程序,端口ACL由Windows防火牆和VFP組合實施。

Windows Server容器

它們使用Windows主機的防火牆 (帶有網絡名稱空間的主機 )和VFP

默認出站:全部允許

默認入站:全部允許(TCP,UDP,ICMP,IGMP)未經請求的網絡流量

拒絕來自這些協議的所有其他網絡流量

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM