0

I encountered a problem. The problem is the docker ps command displays my container's healthy status always as unhealthy

I've reproducted that issue and pushed to Github: https://github.com/korenb/docker-healthcheck-aspnetcore.git

My steps:

  • I configured the healthcheck endpoint in aspnetcore project. The path is /health
  • Then I created docker stuff and set HEALTHCHECK property as desribed in official docs
  • When I run the container I see its status as unhealthy permanently

The check command is curl --fail http://localhost/health || exit 1

I'm surprised that if I run that command through docker exec <container> curl --fail http://localhost/health then it works

I get some logs from docker inspect <container> but I really have no idea what's wrong.

{
    "Status": "unhealthy",
    "FailingStreak": 22,
    "Log": [{
            "Start": "2019-03-12T13:27:51.570474Z",
            "End": "2019-03-12T13:27:51.6708017Z",
            "ExitCode": -1,
            "Output": "OCI runtime exec failed: exec failed: container_linux.go:344: starting container process caused \"exec: \\\"curl --fail http://localhost/health || exit 1\\\": stat curl --fail http://localhost/health || exit 1: no such file or directory\": unknown"
        },
        {
            "Start": "2019-03-12T13:27:53.8550082Z",
            "End": "2019-03-12T13:27:53.9882208Z",
            "ExitCode": -1,
            "Output": "OCI runtime exec failed: exec failed: container_linux.go:344: starting container process caused \"exec: \\\"curl --fail http://localhost/health || exit 1\\\": stat curl --fail http://localhost/health || exit 1: no such file or directory\": unknown"
        }
    ]
}

I'm desperate so I hope the community will help me to figure out the problem

skorenb
  • 629
  • 1
  • 9
  • 16
  • Possible duplicate of [OCI runtime exec failed: exec failed: (...) executable file not found in $PATH": unknown](https://stackoverflow.com/questions/48001082/oci-runtime-exec-failed-exec-failed-executable-file-not-found-in-path) – Ahmet Mar 12 '19 at 17:40

1 Answers1

-1

the devil is in the details

I found out from OCI runtime exec failed: exec failed: (…) executable file not found in $PATH": unknown that the command must be clean of any quotes around.

So in dockerfile I replaced this

HEALTHCHECK ... CMD ["curl --fail http://localhost/health || exit 1"]

by this

HEALTHCHECK ... CMD curl --fail http://localhost/health || exit 1

You can see it here https://github.com/korenb/docker-healthcheck-aspnetcore/commit/6a24b394b9d60bab75d2b7daf549aa86576c2bb5

skorenb
  • 629
  • 1
  • 9
  • 16