首页 > 解决方案 > docker-compose healthcheck for pentaho data integration (pdi)

问题描述

I am building my custom pdi image using docker. I could build image and ran it without any issues. Now I need to add healthcheck for my pdi container. Can anyone suggest me a healthcheck command?

I tried to use,

healthcheck:
      test: /home/data-integration/kitchen.sh -file="/home/jobs/my.kjb" -level=Basic && echo $? || exit 1 

but gives an error as, ERROR: Invalid interpolation format for "healthcheck" option in service "pentaho": "/home/data-integration/kitchen.sh -file="/home/jobs/my.kjb" -level=Basic && echo $? || exit 1"

If I use healthcheck command as below it become unhealthy even there are no any errors.

healthcheck:
      test: /home/data-integration/kitchen.sh -file="/home/jobs/my.kjb" -level=Basic || exit 1 

if I find it from docker inspect containerID, enter image description here

#!/bin/sh
## entrypoint.sh
/home/data-integration/kitchen.sh -file="/home/jobs/my.kjb" -level=Basic
tail -f /dev/null

When I manually run job file and check echo $? it gives 0 as output if job is success. how to use it correctly in to docker-compose healthcheck?

标签: dockerdocker-composeexit-codepentaho-data-integration

解决方案


Being a new user, I cannot comment yet, so I hope this answer gives you something to think about.

Food for thought

Per the Docker documentation on healthchecks, the format is as stated: https://docs.docker.com/engine/reference/builder/#healthcheck

I'm not familiar with your application specifically, but if there is any startup required, then setting a delay to give the container time to initialize may be helpful.

I also see that you're using the same command in your entrypoint script that you are using to healthcheck.

Healthchecks should typically not be the same thing as the running process, and instead should be used to ensure the running process is working correctly. The docs highlight this, as does this blogpost, detailing how to check that a web app is alive by pinging the server.

Another note is that if your entrypoint tails dev null, you will not get the logs of the running process through docker logs. If you want to schedule a task to run often in a container, I recommend wrapping your command in a while loop which calls the command, or using an external orchestrator like Kubernetes Cron Jobs (Edit: Or even a crontab on the host that calls docker run)

Fix

Finally, if you're set on simply fixing the immediate issue of formatting, you need to escape the $ character in the healthcheck, like so:

      test: /home/data-integration/kitchen.sh -file="/home/jobs/my.kjb" -level=Basic && echo $$? || exit 1

Other issues akin to this are: How can I escape a $ dollar sign in a docker compose file?

And it links to the docs on variable escaping here: https://docs.docker.com/compose/compose-file/compose-file-v3/#variable-substitution


推荐阅读