4

I want to start a Docker-container with Oracle XE and then run an SQL script (setup_database.sql) to create some tables in docker-compose.

How can I integrate the following commands into my docker-compose:

docker run -d -p 49161:1521 -v "$PWD":/duo --name duodb --hostname duodb --network duo-test -e ORACLE_ALLOW_REMOTE=true wnameless/oracle-xe-11g-r2

Run a terminal in container:

docker exec -ti duodb /bin/bash

go into the right directory:

cd duo/sql

Kick off the setup_database script:

sqlplus system/oracle@xe @setup_database

I've tried to do run this:

oracle:
    container_name: duodb
    image: wnameless/oracle-xe-11g-r2 
    ports:
        - '49161:1521'
    volumes:
        - .:/duo
    command: ["/bin/bash", "-c", "sqlplus system/oracle@xe @setup_database"]
    environment:
        - ORACLE_ALLOW_REMOTE=true 

But this outputs the following error:

Creating network "duo_default" with the default driver
Creating duodb
Creating duomail
Creating duolocal
Attaching to duomail, duodb, duolocal
duomail      | MailDev webapp running at http://0.0.0.0:80
duomail      | MailDev SMTP Server running at 0.0.0.0:25
duodb        | /bin/bash: sqlplus: command not found
duodb exited with code 127
duolocal     | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.20.0.3. Set the 'ServerName' directive globally to suppress this message
duolocal     | [Fri Nov 15 08:17:55.944907 2019] [ssl:warn] [pid 1] AH01909: 172.20.0.3:443:0 server certificate does NOT include an ID which matches the server name
duolocal     | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.20.0.3. Set the 'ServerName' directive globally to suppress this message
duolocal     | [Fri Nov 15 08:17:55.977329 2019] [ssl:warn] [pid 1] AH01909: 172.20.0.3:443:0 server certificate does NOT include an ID which matches the server name
duolocal     | [Fri Nov 15 08:17:55.980390 2019] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.1.32 OpenSSL/1.1.1d configured -- resuming normal operations
duolocal     | [Fri Nov 15 08:17:55.980423 2019] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
3
  • Can you add the Container Log? Commented Nov 15, 2019 at 8:13
  • I've added the container log Commented Nov 15, 2019 at 8:20
  • can you share your solution please? Commented Feb 17, 2022 at 11:03

2 Answers 2

3

I am not that docker expert, but as far as I know, the network is automatically created with all containers inside a docker-compose file, therefore you do not need the network. Furthermore, you can name the service so I think container-name is also not needed. In which version do you start the compose file? You could try something like this

version: "3"

services:
     duodb:
         image: wnameless/oracle-xe-11g-r2 
         ports:
             - 49161:1521
         volumes:
             - .:/duo
         environment:
             ORACLE_ALLOW_REMOTE=true
             MYSQL_ROOT_USER: root
             MYSQL_ROOT_PASSWORD: secret
             MYSQL_DATABASE: my_database_name
Sign up to request clarification or add additional context in comments.

Comments

-2
version: "3"

services:
  duodb:
    image: wnameless/oracle-xe-11g-r2
    ports:
      - 49161:1521
    volumes:
      - .:/duo
    environment:
      - ORACLE_ALLOW_REMOTE=true
      - MYSQL_ROOT_USER=root
      - MYSQL_ROOT_PASSWORD=secret
      - MYSQL_DATABASE=my_database_name

Comments

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.