Reputation: 2521
I have a ASP .NET Core (v2.0) app with Docker support. And I want to start a Oracle Database when starting my app. This is how my docker-compose file looks like:
version: '3'
services:
devarttestapp:
image: devarttestapp
build:
context: ./DevartTestApp
dockerfile: Dockerfile
oracledb:
image: sath89/oracle-12c
ports:
- "1521:1521"
I use Devart data provider dotConnect for Oracle.
var conn = new Devart.Data.Oracle.OracleConnection();
conn.ConnectionString = Environment.GetEnvironmentVariable("ORACLE_CONNECTION_STRING");
try
{
conn.Open();
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
But when I try to connect to the database of the created Oracle DB container I get following exception:
System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (Connection refused 127.0.0.1:1521)
I also tried to include the depends_on as well as the networks option in my docker-compose file with the same results.
What could be the cause of this exception?
And how do I solve this problem?
Upvotes: 3
Views: 4144
Reputation: 191
Just add SslMode=None;
in your connection string
"ConnectionStrings": {
"DefaultConnection": "Server=db-host; Database=db-name; Uid=db-user; Pwd=db-pwd; SslMode=None;"
},
Upvotes: 0
Reputation: 1111
I faced with the same problem on my mac. I solved it using port that > 9000.
Upvotes: 0
Reputation: 3484
From within the container, can you send me the output of this command?
apt-get update && apt-get install nmap -y && nmap -p 1521 localhost
If you are unfamiliar with how to access bash inside the container, this is how:
Find your container ID or name: docker ps
Connect to BASH: docker exec -it >containerID< /bin/bash
I have a feeling that his issue pertains to Oracle rather than Docker as your docker-compose file looks correct. Perhaps the listener hasn't been enabled. I would also appreciate the output of: lsnrctl status
if nmap
says that the port is not open
.
https://docs.oracle.com/cd/E11882_01/network.112/e41945/listenercfg.htm#NETAG010
Upvotes: 1