将网站添加到Docker的SSL证书

我有一个运行在SSL上的网站,即https,我想部署到Docker Windows容器。 所以我想问一下怎么做,我已经把证书加到容器里了,什么时候用

RUN powershell -NoProfile -Command certmgr.exe -add MyCert.cer -s -r localMachine trustedpublisher 

它给出了这个错误。

certmgr.exe:术语“certmgr.exe”不被识别为cmdlet,函数,脚本文件或可操作程序的名称。 检查名称的拼写,或者如果包含path,请validationpath是否正确,然后重试。

那么你能解释一下怎么做?

certmgr.exe

需要Visual Studio,所以不能在Containers中运行。 如果能帮助任何人,以下是一种方法。 在创build镜像时将其添加到docker文件中

 RUN mkdir C:\cert #cert folder contains the certificates YourCertificate.cer & Name.pfx ADD cert/ /cert RUN powershell -NoProfile -Command \ certutil -addstore "Root" "C:/cert/YourCertificate.cer" RUN powershell -NoProfile -Command \ certutil -importpfx -p "password" "C:/cert/Name.pfx" RUN powershell -NoProfile -Command \ New-WebBinding -Name "YourWebsite" -IP "*" -Port 1234 -Protocol https RUN powershell -NoProfile -Command \ get-item cert:\LocalMachine\MY\thumbprint-of-your-cert | New-Item 0.0.0.0!1234 

1234是您可以绑定到您的网站的端口。 它会将您的网站绑定到证书。