先讲一下场景: nginx 容器要和SpringBoot 容器部署在一台机器上, nginx 为 SpringBoot 提供反向代理, 需要在 nginx.conf 中写上 SpringBoot 的网址, 为了保证 nginx 容器有很好的迁移特性, 反向代理网址自然不能用 IP 来指定 springboot 网址了. 下面是几种做法.
===================================
1. nginx.conf 使用 localhost 来指向 springBoot 系统.
===================================
springBoot 容器按照正常方式启动, 可以加上 docker run -p 8080:8080 这样的端口映射. nginx 容器启动需要使用 docker run --net=host 启动, 不能加 -p 参数(其实加上 -p 参数可以运行, 但端口映射不起作用). 注意一定要