docker - 如何在 Host 模式下使用服务名访问容器?
问题描述
version: "3.3"
services:
test1:
container_name: test1
image: nginx
network_mode: host
restart: always
test2:
container_name: test2
image: nginx
restart: always
如果我想从 访问test1
服务test2
,如何test1
直接通过 ping访问服务test1
?
test1 服务设置为主机模式,不会进行网络隔离。除了使用 IP 直接访问外,如何通过服务名称test1
从容器内访问?test2
test1
解决方案
推荐阅读
- javascript - 这个代码块在 javascript 语法中是什么意思?
- android - Android 展开的 BottomSheetDialogFragment 偏移距离开始折叠
- laravel - Laravel 中的 Pluck 和 Implode 方法?
- swift - 结合使用 CoreData
- python - 有没有更好的方法来引用 numpy 数组的索引(坐标)?
- firebase - @react-native-firebase/messaging 如何自定义通知?
- vector - Rust Lang:结构包含自身的实例?
- javascript - 返回数组中相同项目序列的最大长度
- mysql - MySQL - 避免选择和更新 repeatable_read 上的相同记录
- embedded - 如何在 Simplisity Studio 中将 EFM32LG 参考手册设置转换为 C 设置