Project/토이 프로젝트

[Error] Docker 컨테이너 연결시 : Communications link failure

Lea Hwang 2023. 3. 22. 13:48

언제 발생했는지

도커파일을 도커이미지로  빌드 후 도커 컨테이너 생성 및 실행하는 과정에서 에러가 발생했습니다. 

docker run [도커허브 아이디]/[프로젝트명] -p 8080:8080

 

 

에러 메시지

에러 메시지는 다음과 같습니다.

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

Connection refused (Connection refused)

..... 맨 마지막 에러 메시지

Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

 

 

시도

첫 번째,  Mysql 실행     실패

 

 

두 번째맨 마지막 에러가 hibernate.dialect이므로 혹시나 해서 Application상단 처리     실패

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class Application {
	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

}

 

 

세 번째, build.gradle 수정     실패

configurations {
	compile.exclude group: 'commons-logging', module: 'commons-logging'
    ..
}
dependencies {
	// RDBMS(Mysql)
	implementation 'mysql:mysql-connector-java'

	// hibernate
	implementation 'org.hibernate:hibernate-core'
	implementation 'org.hibernate:hibernate-entitymanager'
}

 

 

 

네 번째, 서비스 또는 서버가 실행 중인지 확인     실패

Applicaion 구동 후 docker run [도커허브 아이디]/[프로젝트명] -p 8080:8080

 

 

다섯 번째, Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set 에러를 해결해보고자 함     실패

spring:
  ...
  jpa:
    database: mysql
    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect

 

 

여섯 번째, 프로젝트 중간에 자바 8에서 11로 변경했던 게 갑자기 생각남, 프로젝트 전반적으로 11로 변경

실패

 

 

일곱 번째, 도커 데스크톱 실행 후 docker-compose -f docker-compose-local.yml up     성공

 

 

 

 

성공

여러 시도 끝에 정상적으로 프로젝트 실행이 되었습니다.😂

 

[정리]
도커 컨테이너 연결, 에러 메시지 : Communications link failure


도커 데스크톱 실행,
터미널에 docker-compose -f docker-compose-local.yml up