【发布时间】:2017-12-14 00:57:37
【问题描述】:
我正在尝试在 docker-compose 中运行 2 个容器。我的 docker-compose.yml 是:
version: '2'
services:
consul:
image: "consul:0.8.3"
hostname: "consul"
command: "agent -server -client=0.0.0.0 -retry-join=10.30.1.97 -retry-join=10.30.1.42 -bootstrap-expect=3 -ui"
ports:
- "8400:8400"
- "8500:8500"
- "8300:8300"
- "8600:53/udp"
vault:
depends_on:
- consul
image: "vault"
hostname: "vault"
links:
- "consul:consul"
environment:
VAULT_ADDR: http://127.0.0.1:8200
ports:
- "8200:8200"
volumes:
- ./tools/wait-for-it.sh:/wait-for-it.sh
- ./config/vault:/config
- ./config/vault/policies:/policies
entrypoint: /wait-for-it.sh -t 20 -h consul -p 8500 -s -- vault server -config=/config/with-consul.hcl
我一开始就遇到的问题是 consul 容器没有使用 IP 10.30.1.134(主机的 IP) 相反,它使用的是我认为的桥接网络:
2017/07/10 10:09:12 [INFO] raft: Node at 172.18.0.2:8300 [Follower] entering Follower state (Leader: "")
如何强制它使用 10.30.1.134?
eth0 链路封装:以太网 HWaddr 06:f5:74:4c:ad:9e
inet 地址:10.30.1.134 广播:10.30.1.255 掩码:255.255.255.0
inet6 地址:fe80::4f5:74ff:fe4c:ad9e/64 范围:链接
UP BROADCAST RUNNING MULTICAST MTU:9001 Metric:1
RX 数据包:9907809 错误:0 丢弃:0 超限:0 帧:0
TX 数据包:17142864 错误:0 丢弃:0 超限:0 运营商:0
碰撞:0 txqueuelen:1000
RX 字节:1328463684 (1.3 GB) TX 字节:2178517759 (2.1 GB)
【问题讨论】: