[英]Can't connect to Azure SQL server using docker
I am new to docker and I can't seem to figure this one out...我是 docker 的新手,我似乎无法弄清楚这个......
I have a spring boot application connected to an azure sql database which is running fine in my IDE, but when running my app in a docker container I am getting the following error: I have a spring boot application connected to an azure sql database which is running fine in my IDE, but when running my app in a docker container I am getting the following error:
"com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host, port 1433 has failed. Error: ".database.windows.net.
“com.microsoft.sqlserver.jdbc.SQLServerException:与主机的 TCP/IP 连接,端口 1433 失败。错误:“.database.windows.net。 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.
确保 SQL 服务器的实例正在主机上运行并在端口接受 TCP/IP 连接。 Make sure that TCP connections to the port are not blocked by a firewall."
确保 TCP 与端口的连接未被防火墙阻止。”
Dockerfile: Dockerfile:
COPY pom.xml /build/
COPY src /build/src/
WORKDIR /build/
RUN mvn package
FROM openjdk:8-jre-alpine
WORKDIR /app
ADD target/spring-boot-docker.jar /app/
ENTRYPOINT ["java", "-jar", "spring-boot-docker.jar"]
application.properties:应用程序属性:
spring.jpa.hibernate.ddl-auto=update
server.port=8081
spring.datasource.url=jdbc:sqlserver://<hidden>.database.windows.net:1433;database=<hidden>;user=<hidden>;password={your_password_here};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
spring.datasource.username=<hidden>
spring.datasource.password=<passhidden>
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
It's going to be a network connectivity issue.这将是一个网络连接问题。
Chances are high that you can't get out from a dynamic internal port to port 1433 on the server, from within the docker container.您无法从 docker 容器内的动态内部端口到服务器上的端口 1433 的可能性很高。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.