티스토리 뷰

window10

 

docker tool box를 사용하는데 다음과 같은 오류가 떴다

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. 

 

 

원인은

docker machine의 ip가 localhost로 접속을 못하기 때문이다 !

 

 

해결방법

1.

docker 컨테이너를 로컬머신의 포트와 연결해주는 옵션이 -p 라는 옵션인데요. 그 옵셥으로 포트를 맵핑하면 localhost로 접근할 수 있습니다.

https://docs.docker.com/config/containers/container-networking/

 

Container networking

The type of network a container uses, whether it is a bridge, an overlay, a macvlan network, or a custom network plugin, is transparent from within the container. From the...

docs.docker.com

 

2.

필자의 경우 이렇게 해결했다.

docker toolbox를 사용하는데 이것을 사용하게 되면 localhost를 사용할 수 없고 docker-machine의 ip 주소를 사용해야한다고 한다.

단, docker for window를 사용하면 localhost를 문제없이 사용할 수 있는 것 같다

 


추가)))

 

기존에 docker for windows를 사용하다가 virtual box를 사용하고 싶어서.

docker tool box로 갈아탔다.( docker for windows보다는 불편하지만, 윈도우에서 ubuntu를 온전하게 사용하기 위해서는 어쩔수 없었다.)

문제는 docker toolbox로 생성한 컨티에너에 접속이 localhost로 안되는 것이었다.

해결방법

다양한 방법이 있겠지만, 복잡하게 네트워크를 변경하는 것보다 기본 도커아이피로 접속하면 된다.

docker-machine ip default 를 입력하면

192.168.99.100 다음과 같은 ip 가 나온다 이 아이피로 접속하면된다.

참고자료

https://stackoverflow.com/questions/42866013/docker-toolbox-localhost-not-working/42886035