Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Docker Oracle Client: Unable to Connect Using tnsnames.ora (ORA-12162 & ORA-12545)

abinandan jabanFeb 15 2025

I'm using the Docker Oracle Client as described in the official repo, but I'm facing an issue connecting to my Oracle database using the tnsnames.ora file.

I have placed my tnsnames.ora file in the default directory:
/usr/lib/oracle/21/client64/lib/network/admin/

Here is my tnsnames.ora configuration:

makefile

XE = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle-xe)(PORT = 1521)) ) (CONNECT_DATA = (SID = XE) (SERVICE_NAME = XE) ) )

My Oracle Database is running in a Docker container named oracle-xe (official image).

What I've Tried:

  • Ping Test: I installed ping inside the client container and confirmed I can ping oracle-xe.
  • SQL Developer Connection: Works perfectly from my Windows machine.
  • Direct SQL*Plus Connection: Inside the container, running:This works fine!

However, when I try connecting using tnsnames.ora in the Oracle Client Docker container, I get:

pgsql

ORA-12162: TNS:net service name is incorrectly specified

When I manually set ORACLE_SID, I get:

pgsql

CopyEdit

ORA-12545: Connect failed because target host or object does not exist

Environment Variables I Tried Setting:

shell

export ORACLE_HOME=/usr/lib/oracle/21/client64/lib export TNS_ADMIN=/usr/lib/oracle/21/client64/lib/network/admin

Still, no success!

I suspect there might be a configuration issue with TNS resolution in Docker, but I am not sure. If anyone has faced a similar issue or has insights on resolving this, please let me know.

For a detailed guide on troubleshooting Oracle Client Docker configurations, you can click here.

shell

sqlplus userName/password@oracle-xe/XE

Comments

Hi.,

May i know which version of database you are using, Is it 19C, if 19C DB then, you are importing into the CDB or Any of PDB Database?

Based on your export command you have issued., I have given 2 scenario to perform as shown below.

expdp user/pass schemas=ctm920 directory=BACKUP_DIRDC logfile=backup.log filesize=1G

If you are using import on Container Database (CDB)

- Check the OS Directory is created & you have linked this OS Directory to DB directory.
Ex: $ mkdir -p /u01/dumpfile/
- Place dumpfile into /u01/dumpfile location.
- SQL> create or replace directory dumpfile as '/u01/dumpfile/';
- SQL> grant read, write on directory dumpfile to [import user];

impdp user/pass dumpfile=expdat.dmp logfile=imp_log.log directory=BACKUP_DIRDC TABLE_EXISTS_ACTION=REPLACE

If you are using import on Pluggable Database (PDB)

- Check the OS Directory is created & you have linked this OS Directory to DB directory.
Ex: $ mkdir -p /u01/dumpfile/
- Place dumpfile into /u01/dumpfile location.
- SQL> create or replace directory dumpfile as '/u01/dumpfile/';
- SQL> grant read, write on directory dumpfile to [import user];

impdp user/pass@(PDB NAME) dumpfile=expdat.dmp logfile=imp_log.log directory=BACKUP_DIRDC TABLE_EXISTS_ACTION=REPLACE

Keep us update.

Warm Regards,
Mir Sayeed Hassan
Oracle ACE Pro
Oracle Certified OCP | OCI

Solomon Yakobson 5 days ago

impdp parameter TABLE_EXISTS_ACTION=REPLACE applies to tables only. Errors you are getting indicate FUNCTION:"ctm920 "."CURRTIME", PROCEDURE:"ctm920 "."PURGE_CMR_RUNINF_1" and FUNCTION:"ctm920 "."DDIFF" already exist in target database. You need to decide do you want to keep there existing objects and for that you need to add EXCLUDE parameters to import or import them and for that you need to drop these objects before import.

SY.

1 - 2

Post Details

Added on Feb 15 2025
0 comments
77 views