Search code examples
oracle-databasedockerdocker-composedockerfile

How do I check if Oracle is up in Docker?


As the title says: how do I check if Oracle is up in Docker? Now my app tries to create a Hibernate session and I'm getting

ERROR :
ORA-01033: ORACLE initialization or shutdown in progress

So I would like some kind of health check having url only. Is that possible? Thank you!


Solution

  • i'm using wnameless/oracle-xe-11g-r2 and this works for me

    version: '3'
    services:
       db:
          image: wnameless/oracle-xe-11g-r2
          environment:
          - ORACLE_ALLOW_REMOTE=true
          ports:
          - 49261:1521
          volumes:
          - ./0_init.sql:/docker-entrypoint-initdb.d/0_init.sql
          healthcheck:
             test: [ "CMD", "bash", "-c", "echo 'select 1 from dual;' | ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe /u01/app/oracle/product/11.2.0/xe/bin/sqlplus -s USERNAME/PASSWORD@localhost"]
             # docker inspect --format "{{json .State.Health }}"  myproject_db_1
             interval: 10s
             timeout: 10s
             retries: 60
       myservice:
          image: xxx
          depends_on:
             db:
                condition: service_healthy