docker安装oracle库的坑

docker运行oracle镜像报错,详情如下:

docker run -d -p 19000:8080 -p 1521:1521  --name oracle12c --restart=always sath89/oracle-12c

1299367555e9ee4fe8db7afe2e42852605652b30598af1302e20dfef75a4193c

docker: Error response from daemon: Ports are not available: listen tcp 0.0.0.0:1521: bind: An attempt was made to access a socket in a way forbidden by its access permissions

从报错来看是因为端口被占用,于是乎查看端口占用情况

netstat -ano

没有发现端口占用

使用 Get-NetTCPConnection |findstr在powershell中也没发现此端口没占用

然后一通百度,原因是windows默认排除了这些端口范围,查看禁用端口的命令如下:

netsh interface ipv4 show excludedportrange protocol=tcp

所以快捷解决方式就是不使用以上范围内的端口。

根本的解决方法如下。原因是Docker for Windows and Hyper-V are responsible for all of those excluded port ranges above.

注:以下方法未亲测,百度到的添加端口的方法

1、先禁用hyper-v(生效需要重启)

dism.exe /Online /Disable-Feature:Microsoft-Hyper-V

2、然后添加要使用的端口

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

3、重新启用hyper-v

dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All

你可能感兴趣的:(docker安装oracle库的坑)