MAC docker --net=host无效

600 阅读1分钟

问题:
docker中nginx无法代理转发到容器外部,且–net=host无效;

原因:
Host 模式只支持 Linux 系统,Windows 和 macOS 此参数无效。因此容器中nginx转发中的localhost是指向容器本身,所以要访问容器外的,需要明确指出宿主机的IP地址。

在这里插入图片描述
官网:docs.docker.com/network/hos…
在这里插入图片描述

另外:当使用云数据库redis时候,即使使用了docker的host模式,还是建议进容器看一下出口ip,然后添加到云redis的白名单中。