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