Zychoo
Zychoo

Reputation: 635

Running two Docker Oracle containers on one Windows Machine

1. What I am trying to achieve

Using Docker for Windows (Docker version 19.03.12, build 48a66213fe) I would like to run in parallel two independent Oracle databases. Image that I am using comes from Oracle Container Registy and is a Oracle Database Standard Edition 2.

2. How am I trying to achieve that

I started one container and it is working fine (using default settings). Run command is:

docker run -d -p 1521:1521 -p 5500:5500 --shm-size="8g" --name=oracle --restart=always container-registry.oracle.com/database/standard

And this one is working perfectly fine. I can connect to DB using my app or DB administration tool.

Then I wanted to start different container using the same image and I used command:

docker run -d -p 1527:1521 -p 5507:5500 --shm-size="8g" --name=OraHib --restart=always container-registry.oracle.com/database/standard

Difference is in port numbers, name of container and I added also confuguration file as described in documentation with different SID for this database.

3. What are the results

After waiting a quarter for my new container to start I am trying to connect to new database I receive error:

Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

Of course, double checked SID, so I am pretty sure that it is correct.

The container is running:

CONTAINER ID        IMAGE                                             COMMAND                  CREATED             STATUS              PORTS                                            NAMES
6047148f17cd        container-registry.oracle.com/database/standard   "/bin/sh -c '/bin/ba…"   15 minutes ago      Up 15 minutes       0.0.0.0:1527->1521/tcp, 0.0.0.0:5507->5500/tcp   OraHib
694120faf51c        container-registry.oracle.com/database/standard   "/bin/sh -c '/bin/ba…"   4 weeks ago         Up 3 hours          0.0.0.0:1521->1521/tcp, 0.0.0.0:5500->5500/tcp   oracle

What is in docker logs:

docker logs OraHib
User check : root.
Setup Oracle Database
Oracle Database 12.1.0.2 Setup
Tue Oct 6 11:48:21 UTC 2020

Check parameters ......
log file is : /home/oracle/setup/log/paramChk.log
paramChk.sh is done at 0 sec

untar DB bits ......
log file is : /home/oracle/setup/log/untarDB.log
untarDB.sh is done at 117 sec

config DB ......
log file is : /home/oracle/setup/log/configDB.log
ERROR : config DB failed, please check log /home/oracle/setup/log/configDB.log for details!
Tue Oct 6 11:48:21 UTC 2020
User check : root.
Setup Oracle Database

In mentioned configDB.log file there is:

Start Docker DB configuration
Call configDBora.sh to configure as oracle user
Argument(s) Error... Patch not present in the Oracle Home, Rollback cannot proceed
If the patch was applied using -no_inventory option, use -ph option
to specify the patch shiphome location. Use 'opatch rollback -help'
to get more information.

ERROR : ORA- errors detected, config DB ora failed, please check log /home/oracle/setup/log/configDBora.log for details!
Docker DB configuration failed ...

The last log file configDBora.log consists what is in this pastebin - it is a bit longer than the first one.

What I also tried
Multiple different configurations of ports.
Changing SID of database
Tried on different computer

Does anyone have any clue why this seems impossible? I spent a lot of time on that and still don't have a single idea why it cannot run.

Upvotes: 2

Views: 1647

Answers (2)

SuperPoney
SuperPoney

Reputation: 670

I think the image has a bug when changing the Oracle Enterprise manager default port. Just omit it and it will work:

docker run -d -p 1527:1521 --shm-size="8g" --name=OraHib
--restart=always container-registry.oracle.com/database/standard

docker run -d -p 1528:1521 --shm-size="8g" --name=OraHib2
--restart=always container-registry.oracle.com/database/standard

This is not perfect since this will deactivate EM (ie port is not available). But if you dont use it (like me) this won't be a problem.

Upvotes: 1

SuperPoney
SuperPoney

Reputation: 670

(sorry I can't comment yet so my only solution to ask something is by posting an "answer").

Maybe your 2 containers are trying to use the same volume?

I suppose Oracle images are based on the following repo: https://github.com/oracle/docker-images/tree/master/OracleDatabase/SingleInstance

Can you check if the official Oracle Container Registry image does not hard code a default volume for the data; by specifing a default -voption with a docker inspect on your running images.

-v [<host mount point>:]/opt/oracle/oradata


UPDATE

It seems that this feature is not enabled yet in this image. If you look at the setup script inside a running container we can see that the listener port is hard coded with 1521 and does not use the exposed port :

su oracle
vi /home/oracle/setup/configDBora.sh

Port is hard coded:

[...]
echo "SSL_VERSION = 1.0"  >> $LSNR_ORA
# tnsnames.ora
TNS_ORA=$ORACLE_HOME/network/admin/tnsnames.ora
echo "$DB_SID = \
  (DESCRIPTION = \
    (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521)) \
    (CONNECT_DATA = \
      (SERVER = DEDICATED) \
      (SERVICE_NAME = $DB_SID.$DB_DOMAIN) \
    ) \
  ) \
" >> $TNS_ORA
echo "$DB_PDB = \
  (DESCRIPTION = \
    (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521)) \
    (CONNECT_DATA = \
      (SERVER = DEDICATED) \
      (SERVICE_NAME = $DB_PDB.$DB_DOMAIN) \
[...]

I'll sugest you to try with another version, or use the script from Oracle Github.

Upvotes: 1

Related Questions