java - docker-compose 创建一个不在公司 VPN 内的网络
问题描述
介绍
- 我有一个在 docker 容器内运行的微服务。
- docker 容器在公司的服务器(Debian 10)上运行。
- 服务器的 IP 地址是 141.45.146.55。
- 该公司的 IP 地址的格式为 141.45.0.0/16(请参阅下面的 iptables 规则)。
- 此微服务需要与具有以下 IP 地址的另一台服务器通信:141.45.11.192。
问题
一切正常,直到我打开以下 VPN:
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere state ESTABLISHED
ACCEPT all -- anywhere anywhere
ACCEPT all -- 141.45.0.0/16 anywhere
ACCEPT tcp -- anywhere anywhere tcp dpt:8443 state NEW,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:8636 state NEW,ESTABLISHED
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain DOCKER (0 references)
target prot opt source destination
ACCEPT tcp -- anywhere 172.18.0.2 tcp dpt:postgresql
ACCEPT tcp -- anywhere 172.18.0.3 tcp dpt:https
ACCEPT tcp -- anywhere 172.18.0.4 tcp dpt:https
ACCEPT tcp -- anywhere 172.18.0.5 tcp dpt:https
Chain DOCKER-ISOLATION-STAGE-1 (0 references)
target prot opt source destination
Chain DOCKER-ISOLATION-STAGE-2 (0 references)
target prot opt source destination
Chain DOCKER-USER (0 references)
target prot opt source destination
mircoservice 现在抛出异常Caused by: java.net.ConnectException: Connection timed out
到目前为止我做了什么
查看 iptables 规则我们可以看到 docker-compose 创建的网络地址与公司的 IP 地址不同。所以我认为这就是重点,因为如果我在公司网络之外,我将无法连接到目标服务器。
问题
如何将 docker(-compose) 和/或防火墙配置在公司的 VPN 内部,以便被“另一台服务器?
解决方案
推荐阅读
- python - 在图中找到 N 条最短路径
- reactjs - 限制 React 应用程序中的用户表单访问页面
- firebase - 如何为空检查设置 Firebase 规则
- javascript - 将 UTC 时间戳解析为本地时间,忽略时区
- javascript - 如果有办法做背景尺寸:覆盖并仍然能够滚动图像
- java - 如何检测演员播放完毕?
- python - 无法使用瓶颈包计算移动平均值-python
- matlab - 通过施加条件删除特定行
- sql - 如何在 SQL 中使用 LIKE 子句及其通配符函数将单个条件/参数组合为一个条件/参数?
- ios - IOS TableView第一个单元格图像应该从状态栏开始