Docker container can't connect to same db server and port multiple times


This may be a basic question but I can’t seem to find the answer to it and have been struggling for a couple of days with it. We have an application that we’re trying to run in a Docker container, and it has around 33 datasources. Half of these datasources connect to the same database and database port but with a different database schema.

Version: 17.03.2-ee-6
API version: 1.27 (minimum version 1.12)

So an example of this is we need the application to have 10 outgoing connections to the same db server and port:

dbServer1 : 9990 : schema1
dbServer1 : 9990 : schema2
dbServer1 : 9990 : schema3

dbServer1 : 9990 : schema10

dbServer2 : 1521 : schema 11
dbServer2 : 1521 : schema 12

I first tried running the container with -p 9990 : 9990 -p 1521 : 1521
The first datasource can be created fine for dbServer1 and dbServer2, but after that the others fail with “connect timed out” because the port is already being held and they can’t get use it.

I also tried -p 8601-8900:9990 -p 8901-8950:1521
-P --expose 9990 --expose 1521

Normally in linux it would just map ephemeral ports to the outgoing connections and would work fine, like this on our existing Weblogic servers:
netstat -nap

tcp 0 0 ESTABLISHED 47119/java
tcp 0 0 ESTABLISHED 47119/java
tcp 0 0 ESTABLISHED 18303/java
tcp 0 0 ESTABLISHED 47119/java
… (29 more entries)

Any help would be greatly appreciated. I know there’s got to be something simple I’m missing, because servers assign these ports all the time for outgoing communication and we have servers with hundreds of connections open to the same database server and port.


-p is only for incoming connections. You don’t need to configure anything special for outgoing connections.

Yeah, that should work fine…it’s not clear to me what your problem might actually be (the same netstat commands you already know how to run are a good place to keep digging) but it’s pretty unlikely that any combination of -p, -P, and --expose will help.