Local database docker to AWS database in VPN

i’m a beginner to Docker, hope everyone can help, much appreciated.

I downloaded a docker image from my company repository and i managed to create a container in my local machine from the image, let’s named it mydb. It is created through command below:
docker run –name mydb -p 1521:1521 -d mycompany.com:5000/docker-db:20.0.04

I am able to access the database with following connection string through my sqldqveloper : system/[email protected]:1521/ORCL

Our company have a database server in AWS, let’s name it awsdb. I can access it after vpn login.
I am able to access the database with following connection string in sqldqveloper :
system/[email protected]:1521/awsdb

Question:
How can i create a database link in mydb to awsdb with database link "my_dblink"? eg. select sysdate from [email protected]_dblink.

I try with following command:

CREATE PUBLIC DATABASE LINK my_dblink
CONNECT TO system
IDENTIFIED BY abc123
USING 'awsdb.amazonaws.com:1521/awsdb';

but it return error ORA-12543: TNS:destination host unreachable.

I tried remove the container and recreated it by set the net=host:
docker run –name mydb -p 1521:1521 -d –net=host mycompany.com:5000/docker-db:20.0.04
then now i can’t even connect is with system/[email protected]:1521/ORCL
error ORA-12541 returned: no listener.

How can i open the connection between internal docker to AWS database server? Thank you.

Source: Docker Questions

LEAVE A COMMENT