I have created docker file to import SSL certificate in IIS container. It throws some errors while building docker file.
Docker file I used
# escape=`
FROM mcr.microsoft/dotnet/framework/aspnet:4.8
# Enable Web Management Service and configure for remote management
RUN powershell Install-WindowsFeature Web-Mgmt-Service; `
New-ItemProperty -Path HKLM:\software\microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1 -Force; `
Set-Service -Name wmsvc -StartupType automatic
RUN net user iisadmin Password1 /ADD
RUN net localgroup administrators iisadmin /ADD
RUN powershell c: mkdir volume
RUN powershell c: mkdir /etc/ssl/certs/
COPY Designvaultprivatekey.pfx /etc/ssl/certs/
ARG PFX_PASSWORD=test123
# Import the PFX certificate using PowerShell
RUN powershell -Command "`
$ErrorActionPreference = 'Stop';
$password = ConvertTo-SecureString -String '$env:PFX_PASSWORD' -Force -AsPlainText;
Import-PfxCertificate -FilePath '/etc/ssl/certs/Designvaultprivatekey.pfx' -CertStoreLocation '/path/to/your/certificate/store' -Password $password;
`"
- Error I recived
Error response from daemon: dockerfile parse error on line 20: unknown instruction: $password
Use this command to run above docker file
docker build --build-arg PFX_PASSWORD=test123 -t (imagename) .
Can anybody provide some guidance on how to resolve the above issue and how to properly import the SSl certificate into the IIS windows container ?
I have created docker file to import SSL certificate in IIS container. It throws some errors while building docker file.
Docker file I used
# escape=`
FROM mcr.microsoft/dotnet/framework/aspnet:4.8
# Enable Web Management Service and configure for remote management
RUN powershell Install-WindowsFeature Web-Mgmt-Service; `
New-ItemProperty -Path HKLM:\software\microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1 -Force; `
Set-Service -Name wmsvc -StartupType automatic
RUN net user iisadmin Password1 /ADD
RUN net localgroup administrators iisadmin /ADD
RUN powershell c: mkdir volume
RUN powershell c: mkdir /etc/ssl/certs/
COPY Designvaultprivatekey.pfx /etc/ssl/certs/
ARG PFX_PASSWORD=test123
# Import the PFX certificate using PowerShell
RUN powershell -Command "`
$ErrorActionPreference = 'Stop';
$password = ConvertTo-SecureString -String '$env:PFX_PASSWORD' -Force -AsPlainText;
Import-PfxCertificate -FilePath '/etc/ssl/certs/Designvaultprivatekey.pfx' -CertStoreLocation '/path/to/your/certificate/store' -Password $password;
`"
- Error I recived
Error response from daemon: dockerfile parse error on line 20: unknown instruction: $password
Use this command to run above docker file
docker build --build-arg PFX_PASSWORD=test123 -t (imagename) .
Can anybody provide some guidance on how to resolve the above issue and how to properly import the SSl certificate into the IIS windows container ?
Share Improve this question asked Nov 20, 2024 at 6:00 sheiksheik 14 bronze badges1 Answer
Reset to default 0The previous line ($ErrorActionPreference = 'Stop';) is missing the ` character so the next line stays inside the PowerShell command.