I am struggling with creating a user automatically in dockerized Oracle db 12c. I manage building up an instance of Oracle db, but I would also like to create a user there just after initialization is complete (it takes about 10 min to be up and running).
FROM example/database:12c COPY entry_point.sh ./ ENV ORACLE_SID="ORCLCDB" ENV ORACLE_PDB="ORCLCPDB1" ENV ORACLE_PWD="example123" ENTRYPOINT ./entry_point.sh
#!/bin/bash exec $ORACLE_BASE/$RUN_FILE sqlplus SYS/example123 as SYSDBA <<EOF <--- part that does not run at all alter session set container=ORCLCPDB1; create user EXUSER identified by example1234; grant create session to EXUSER; EOF
docker image build -t oracle-db . docker run --rm --name oracle-container -p 1521:1521 -p 5500:5500 -d oracle-db
After running those snippets the database comes up properly, I can log in there and so on (e.g create a user with exact the same commands manually). The only issue is that entry_script.sh run only
exec $ORACLE_BASE/$RUN_FILE and the leftover part where admin logs to the db and create a user is somehow omitted. I know
exec command runs another shell in this case but when I remove it and run a standalone script nothing changes at all. I have tried many different approaches to automate the task of creating a user just after the db is up yet unsuccessfully. Do you have any suggestions?