I faced with the following issue:
the container is running with the following healthcheck config (test
is in question)
healthcheck:
test: ["CMD-SHELL", "curl -s -X GET http://127.0.0.1:5000/actuator/health", "|", "grep 'UP'"]
interval: 30s
timeout: 3s
retries: 3
start_period: 10s
in runtime I see that only the first part of the healthcheck test command (curl -s -X GET http://127.0.0.1:5000/actuator/health
) is considered.
The endpoint answers with status: Down, but healthcheck is passed - "Status": "healthy"
:
docker inspect 1f074dc72c6d | grep -i -A 10 health
"Health": {
"Status": "healthy",
"FailingStreak": 0,
"Log": [
{
"Start": "2019-12-10T11:37:46.215783033Z",
"End": "2019-12-10T11:37:46.315844469Z",
"ExitCode": 0,
"Output": "{\"status\": \"DOWN\"}"
},
{
"Start": "2019-12-10T11:38:16.346253717Z",
--
"Healthcheck": {
"Test": [
"CMD-SHELL",
"curl -s -X GET http://127.0.0.1:5000/actuator/health",
"|",
"grep 'UP'"
],
"Interval": 30000000000,
"Timeout": 3000000000,
"StartPeriod": 10000000000,
"Retries": 3
CMD-SHELL
takes one argument, the string gets passed to a shell that handles parsing the string:
test: ["CMD-SHELL", "curl -s -X GET http://127.0.0.1:5000/actuator/health | grep 'UP'"]