MaksymBilenko / docker-oracle-12c

:whale: Docker image with Oracle Database 12c on board
Apache License 2.0
687 stars 289 forks source link

Include Healthcheck #61

Open mgansler opened 7 years ago

mgansler commented 7 years ago

It would be nice for the container to have a health status. Here is what I have come up with in compose, but maybe there is a better way and I think it would be great to have the healthcheck included in the image itself.

services:
  database:
    image: sath89/oracle-12c:r1
    healthcheck:
      test: ["CMD-SHELL", "if [ \"`echo \\\"SELECT ACCOUNT_STATUS FROM DBA_USERS WHERE USERNAME = 'ANONYMOUS' AND ACCOUNT_STATUS = 'EXPIRED';\\\"|/u01/app/oracle/product/12.1.0/xe/bin/sqlplus -S sys/oracle as sysdba|grep ACCOUNT_STATUS`\" = \"ACCOUNT_STATUS\" ];then true;else false;fi"]
      timeout: 3s
      interval: 30s
      # start_period: 900s
      retries: 30

"start_period" is commented out because https://github.com/docker/cli/pull/475 has been merged but not released yet so compose doesn't support it (yet). "interval" and "retries" can be modified.

0xERR0R commented 7 years ago

This variant seems to work too:


      test: echo "select * from v\$database;" | sqlplus -S sys/oracle as sysdba || exit 1
      timeout: 3s
      interval: 30s
      retries: 30
kakawait commented 6 years ago

@MaksymBilenko regarding existing comment what do you except with help wanted flag? I think we could use one of them test and include inside Dockerfile

tjheslin1 commented 6 years ago

I have written an application to monitor oracle databases, serving this very purpose. If you need help configuring it please feel free to raise an issue:

https://github.com/tjheslin1/Patterdale