I created a script in python (healthcheck.py) to check some dependencies in my container.
Something like:
try:
connect with RabbitMQ
sys.exit(0)
except Exception:
sys.exit(1)
Then in my Dockerfile I added the line
HEALTHCHECK CMD [“python”, “/app/healthcheck.py”]
This seems to work fine, even when I run docker inspect
I get response from health checks running
"Health": {
"Status": "healthy",
"FailingStreak": 0,
"Log": [
{
"Start": "2024-06-11T16:41:41.275336909-03:00",
"End": "2024-06-11T16:41:41.543611865-03:00",
"ExitCode": 0,
"Output": ""
},
{
"Start": "2024-06-11T16:41:53.544584312-03:00",
"End": "2024-06-11T16:41:53.805990045-03:00",
"ExitCode": 0,
"Output": ""
},
...
]
}
},
But I have two cuestions:
- Is it correct to call the script python directly?
- How could I add information to the Output field? I mean, how should I log into my script so that Output is not empty?
Thanks!
New contributor
Estefania De Elia is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2