Home > Blockchain >  Unable to execute powershell command in docker
Unable to execute powershell command in docker

Time:12-13

I am trying to execute the PowerShell script in docker using the docker file through Jenkins. Previously, it was working fine with the same Dockerfile but now it's failing.. Can anyone help me on this

FROM mcr.microsoft.com/powershell
WORKDIR /app
COPY htmlReport.ps1 /app
COPY report.json /app
RUN ["pwsh", "htmlReport.ps1"]

below is error jenkins giving

Step 1/5 : FROM mcr.microsoft.com/powershell
latest: Pulling from powershell
e96e057aae67: Pulling fs layer
06c4b2188acf: Pulling fs layer
e96e057aae67: Verifying Checksum
e96e057aae67: Download complete
06c4b2188acf: Verifying Checksum
06c4b2188acf: Download complete
e96e057aae67: Pull complete
06c4b2188acf: Pull complete
Digest: sha256:fe812277f0695af7846ad0cbf9a010e157ffa89ac78c9435b72ff0f1adb8435c
Status: Downloaded newer image for mcr.microsoft.com/powershell:latest
 ---> 925e63c2bfe6
Step 2/5 : WORKDIR /app
 ---> Running in 8618b46d44dd
Removing intermediate container 8618b46d44dd
 ---> 449979b5c145
Step 3/5 : COPY htmlReport.ps1 /app
 ---> 2f3b5600eedc
Step 4/5 : COPY report.json /app
 ---> bf784e946fc2
Step 5/5 : RUN ["pwsh", "htmlReport.ps1"]
 ---> Running in 22e7ae2434ba
Failed to create CoreCLR, HRESULT: 0x80070008
The command 'pwsh htmlReport.ps1' returned a non-zero code: 137
Build step 'Execute shell' marked build as failure

CodePudding user response:

I found a solution. The Docker file should be like below

FROM mcr.microsoft.com/powershell:7.1.3-ubuntu-20.04
WORKDIR /app
COPY htmlReport.ps1 /app
COPY report.json /app
#RUN ["pwsh", "htmlReport.ps1"]
RUN pwsh -File './htmlReport.ps1'
  • Related