개발/Docker

[Docker] Ports are not available 에러

IamBD 2022. 5. 27. 14:18

ERROR: for frontend Cannot start service frontend: Ports are not available: listen tcp 0.0.0.0:3306: bind: An attempt was made to access a socket in a way forbidden by its access permissions.

 

Docker에 my-sql 올려놓고 사용중 어느날 갑자기 Ports are not available 에러가 발생했다.

 

문자 그대로 해석하면 해당 포트에 접근 권한이 없다고 나온다 (mysql 3306 포트)

 

검색해보니 어떤 이유인지는 모르겠으나 윈도우 자체에서 해당 포트를 막고있었는데 관리되는 포트는

 

netsh interface ipv4 show excludedportrange protocol=tcp

 

명령어로 확인이 가능하다.

 

윈도우측에서 이유가 있으니 막아뒀겠지만 다른 포트가 아닌 막혀있는 포트를 사용하고자 한다면 다음과 같이 해결이 가능하다.

 

1. 필요한 포트가 제한되어 있는지 확인

netsh interface ipv4 show excludedportrange protocol=tcp

 

2. 해당 포트가 제한되어 있다면 winnat 중지

net stop winnat

 

3. 사용하고자 하는 포트에 대한 제한 금지 (필자는 3306)

netsh int ipv4 add excludedportrange protocol=tcp startport=3306 numberofports=1

 

4. winnat 재시작

net start winnat

 

 

출처

https://github.com/docker/for-win/issues/3171

 

Unable to bind ports: Docker-for-Windows & Hyper-V excluding but not using important port ranges · Issue #3171 · docker/for-wi

I have tried with the latest version of my channel (Stable or Edge) I have uploaded Diagnostics Diagnostics ID: BB0297BB-C287-4F0B-A007-72B5F2D7BD72/20190102235413 Expected behavior Be able to bind...

github.com