I want to start a Docker-container with Oracle XE and then run an SQL script (ddl.sql) to create some tables in docker-compose.
If I execute all the steps separately, everything works:
$ docker run -d --name db --rm -p 49161:1521 -v "C:/data/workspace/vpk/":/home/vpk -e ORACLE_ALLOW_REMOTE=true wnameless/oracle-xe-11g
Run a terminal in container:
$ docker exec -it db bash
Execute the script:
root@f3ae34d554af:/# echo exit | sqlplus system/oracle@xe @/home/vpk/ddl.sql
However when I tried to run everything via docker-compose (excerpt from YML is below)
version: "2"
services:
...
db:
image: wnameless/oracle-xe-11g
container_name: vpk-db
volumes:
- ./ddl.sql:/home/vpk/ddl.sql
command: sqlplus system/oracle@xe @/home/vpk/ddl.sql
ports:
- 49161:1521
environment:
- ORACLE_ALLOW_REMOTE=true
networks:
- default
I got the error:
ERROR: for 2237511031b6_vpk-db Cannot start service db: b'OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \\"sqlplus\\": executable file not found in $PATH": unknown'
ERROR: for db Cannot start service db: b'OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \\"sqlplus\\": executable file not found in $PATH": unknown'
Encountered errors while bringing up the project.
Ok. I found out the full path to sqlplus
root@558a4c1f74b9:/# whereis sqlplus
sqlplus: /u01/app/oracle/product/11.2.0/xe/bin/sqlplus
and inserted it in docker-compose
$ docker-compose.exe up
Removing vpk-db
Recreating 2237511031b6_vpk-db ... done
Attaching to vpk-db
vpk-db | Error 6 initializing SQL*Plus
vpk-db | SP2-0667: Message file sp1<lang>.msb not found
vpk-db | SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
vpk-db exited with code 1
What is going on? Do I log in as a different user when I run docker-compose instead of just docker run ... image ?