I am working with Docker and I have created a Dockerfile which converts my dotnet application into an image. I can then run this image and everything is working fine. I am using mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-1809 AS base.
Now, I wanted to add the 'HealthCheck' feature of Docker. In that HealthCheck, I want to use some Powershell logic, but from the moment I use Powershell, de HealthCheck gets classified as unhealthy.
For example:
HEALTHCHECK CMD powershell -command exit 0
Results in an unhealthy container.
For example:
HEALTHCHECK CMD exit 0
Results in a healthy container
Any powershell logic I try to insert, which either returns or exits a 0, give me unhealthy containers. Right now, I'm thinking that it is the powershell just erroring whatever the logic is.
Anyone can hint at what I am doing wrong to get some powershell code login inside my Docker Healthcheck? I need this powershell code within the HealthCheck for a specific reason which is not really important.
Thanks
EDIT: I have also tried:
HEALTHCHECK CMD powershell -command return 0
and
HEALTHCHECK CMD powershell -command Write-Host 0
Both with the same result: an unhealthy container.