我有一个运行在ssl上的网站,即https,我想用Docker Desktop for Windows将它部署到Docker Windows Containers。所以我想问一下它是如何完成的,我已经将证书添加到容器中,以及何时使用
RUN powershell -NoProfile -Command certmgr.exe -add MyCert.cer -s -r localMachine trustedpublisher
它给出了这个错误。
certmgr.exe:术语“certmgr.exe”未被识别为cmdlet,函数,脚本文件或可操作程序的名称。检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。
所以你能解释一下它会怎么做?
certmgr.exe
需要Visual Studio,因此它无法在容器中运行。以下是一种方法,如果它可以帮助任何人。在创建映像时,在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是您可以与您的网站绑定的端口。它会将您的网站绑定到证书。