1

Is it possible to start another service, in that case a java spring application, after the oracle database start? I know there is a depends_on and health_check but did not work for me:

docker-compose:

version: '3.4'
services:
  oracle-xe:
    image: preloaded_db:latest
    container_name: oracle
    ports:
      - "1521:1521"
    environment:
      - ORACLE_PASSWORD=oracle
  app:
    build:
      context: ./app
      dockerfile: Dockerfile
    ports:
      - "8080:8080"
    depends_on:
      - oracle-xe

and also my custom image dockerfile:

FROM gvenzl/oracle-xe:latest

COPY *.sql /docker-entrypoint-initdb.d/
Soheil Babadi
  • 562
  • 2
  • 4
  • 15
tony_rosey
  • 21
  • 3
  • You could try using the `condition` attribute, see the [docker docs](https://docs.docker.com/compose/compose-file/05-services/#depends_on). Alternatively, you can use something like a [wait-for-it script](https://stackoverflow.com/questions/60539114/how-to-wait-for-mssql-in-docker-compose). – Rob Jul 12 '23 at 06:22

1 Answers1

0

You have to:

  1. Write a startup script that waits for Oracle startup then runs your sprint application.
  2. Copy it into your custom image.
  3. Run it by the docker CMD command.
Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74