0

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 ?

1 Answer 1

1

Try to use the next in the docker-compose file:

command: ["/bin/bash", "-c", "sqlplus system/oracle@xe @/home/vpk/ddl.sql"]

U don't have environment without a shell, so call it directly

Sign up to request clarification or add additional context in comments.

1 Comment

I get Starting vpk-db ... done Attaching to vpk-db vpk-db | /bin/bash: sqlplus: command not found vpk-db exited with code 127 It looks the command tries to run a local sqlplus, not the sqlplus installed on docker container

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.