启动Docker的时候经常出现端口被占用,restart又好了,但是又出现无法连上或者其他莫名其妙的问题,困扰了很久。
An attempt was made to access a socket in a way forbidden by its access permissions.
ERROR: for mysql Cannot start service mysql: 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.
ERROR: Encountered errors while bringing up the project.
经过查找发现,是端口被占用了,web访问或者其他的一些操作把端口占了,导致程序无法启动或者链接上错误的程序。
解决方案
修改前
netsh int ipv4 show dynamicport tcp
协议 tcp 动态端口范围
---------------------------------
启动端口 : 1024
端口数 : 64511
执行下面两行脚本修改
netsh int ipv4 set dynamicport udp start=49152 num=16383
netsh int ipv4 set dynamicport tcp start=49152 num=16383
修改后
netsh int ipv4 show dynamicport tcp
协议 tcp 动态端口范围
---------------------------------
启动端口 : 49152
端口数 : 16383