oracle-databasedockerdocker-composeimpdp

How to health check oracle docker container where import (impdp) of data is running


I have a oracle docker container where import of dump has to run using impdp command. After the import has finished successfully with no errors, the container should become healthy and next process should start. Is there a way to define some query/command which will tell that import is finished -> container is healthy.

I have tried so far:

    healthcheck:
        test: ["CMD", "bash", "-c", "echo 'SELECT * FROM V\$VERSION;' | sqlplus / as sysdba"]
        interval: 20s
        timeout: 20s
        retries: 60

But the problem with that is, the container becomes healthy while the import is still executing. Actually i want to relate health status of container as "healthy" only if the import has finished successfully otherwise unhealthy.


Solution

  • One way is to try to use the standard monitoring of impdp as described in oracle forum or in this blog and construct a health check out of it.

    You can use count(*) to find how many data pump processes are running, and once the count is 0, you are healthy. This would be to long and complex to do it in a single line, so writing as small script (bash, python, ...) would help.

    To make the check more robust, wait for the data import process to start (count > 0) and after that wait to finish (count = 0) to avoid cases where the script had run before the data import started.

    As alternative, you can use ps to check if the process is still running. Based on this blog the process name would be expdp, however you can verify what is the correct process name for your case.