'unable to execute oracle data setup script from docker compose

I am trying to set up oracle data once my oracle container is up and running, below is my compose file:

version: '3'
services:
  oracle:
   image: absolutapps/oracle-12c-ee
   container_name: oracle-docker
  ports:
  - 8080:8080
  - 1521:1521
  environment:
    CASSANDRA_BROADCAST_ADDRESS: 127.0.0.1
    ORACLE_ALLOW_REMOTE: "true"
  volumes:
  - ./scripts/oracle-init.sh:/oracle-init.sh

oracle-init.sh:

#!/usr/bin/env bash
echo "### SETUP EXECUTION! ###"
sqlplus -s "system/oracle@localhost:1521/orcl /scripts/init-oracle.sql"
echo "### SETUP EXECUTED! ###"

init-oracle.sql :

CREATE USER ot_consumer_tryout IDENTIFIED BY ot_consumer_tryout; Can anyone help me what is wrong with above snippets. My docker container getting started but sql script does not execute ,here is the log from terminal:

oracle-docker | Running init scripts... oracle-docker | Init scripts in /oracle.init.d/: Ignoring /oracle.init.d/* oracle-docker | oracle-docker | Done with scripts we are ready to go



Solution 1:[1]

Look at the volume you created

- ./scripts/oracle-init.sh:/oracle-init.sh

which means inside your container the file is in '/oracle-init.sh' but your container might be expecting in a different location something with folder name oracle.init.d as per your container log.

oracle-init.sh is trying to run /scripts/init-oracle.sql , hope your image already has it otherwise you will have to mount it as well in compose file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vijay