Docker Community Forums

Share and learn in the Docker community.

How to access Database using domain name from windonws docker container

docker

(Dvekaria) #1

Getting error as below:

Error: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host *(my database server ip address), port *(database port) has failed. Error: "connect timed out. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall. ".

Database string: jdbc:sqlserver://dns:port;DatabaseName=testdb

Using Docker Windows container

DockerfileWar:

FROM openjdk:8
ADD target/dv-2.war dv-2.war
EXPOSE 8085
ENTRYPOINT ["java","-jar","dv-2.war"]

Build image from Project: docker build -f DockerfileWar -t dv-2war .

docker run -p 8085:8085 dv-1war

Getting above error while run the container.

Note: If i used the IP address at DNS than it is working. But i want to do with DNS only. Just for note database running on some other machine(Not on any container). Spring boot application running on docker windows container.