Connection refused during running app on docker - Spring Boot & mssql server

Multi tool use


Connection refused during running app on docker - Spring Boot & mssql server
I'm start to play with Docker. I'm trying to run Spring Boot application on Docker which connects with mssql-server-linux on docker. I'm configure and run mssql server. My app has set database port and when I run this app in IntelliJ everything is ok. Also when I build app './mvnw install dockerfile:build' command everything is ok. Also adds entity to database during build. When I try run app 'docker run' command I get this exception:
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused. 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.".
What's the problem?
My spring boot app properties:
spring.datasource.username=sa
spring.datasource.password=ABCabc123!
spring.datasource.url=jdbc:sqlserver://localhost:1433;databaseName=DockerApp
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.jpa.hibernate.ddl-auto=update
Dockerfile:
FROM java:8
VOLUME /tmp
ARG JAR_FILE
COPY ${JAR_FILE} docker-app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-
jar","/docker-app.jar"]
CMD ["-start"]
My build options in pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.3.6</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>my-repo</repository>
<tag>${project.version}</tag>
<pullNewerImage>false</pullNewerImage>
<useMavenSettingsForAuth>true</useMavenSettingsForAuth>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.