启动容器是时以下错误:
(HTTP code 500) server error - Ports are not available: exposing port TCP 0.0.0.0:5432 -> 0.0.0.0:0: listen tcp 0.0.0.0:5432: bind: An attempt was made to access a socket in a way forbidden by its access permissions.
检查win端口是否占用(示例5432端口):
netstat -ano | findstr :5432
如果没有进程占用端口,那应该是系统Hyper-V动态分配端口占用了,可以使用以下方式释放:
- 首先停用winnat
net stop winnat
- 启动容器(或者界面应用中打开)
docker start container_name
- 恢复winnat
net start winnat
参考:
Windows Docker 端口占用错误解决
Ports are not available: listen tcp 0.0.0.0/50070: bind: An attempt was made to access a socket in a way forbidden by its access permissions