gpt4 book ai didi

docker - 领事+领事代理

转载 作者:行者123 更新时间:2023-12-02 08:46:35 27 4
gpt4 key购买 nike

帮助理解consul节点和consul代理的启动。我有一个虚拟机,其上有 consul +Vault + 2 consul 节点。在 VM 3 ip LAN 中。所有这些都在 Docker 容器中。当我尝试从另一个虚拟机连接到该领事时。那么agent连接到第一个控制台,无法连接到consul的其他节点。

据我了解,我需要在单独的 ip 主机虚拟机上运行所有 3 个控制台节点,这样才能访问它们的 consul 代理。只是如何做到这一点?

我用这个 docker-compose 启动 consul +Vault:

version: "2"
services:
consul1:
image: "consul.1.0.1"
container_name: "consul12"
hostname: "consul12"
volumes:
- ./consul/config:/config/
ports:
- "8400:8400"
- "8500:8500"
- "8600:53"
- "8300:8300"
- "8301:8301"
command: "agent -config-dir=/config -ui -server -bootstrap-expect 3"
consul2:
image: "consul.1.0.1"
container_name: "consul2"do
hostname: "consul2"
volumes:
- ./consul/config:/config/
expose:
- "8400"
- "8500"
- "8600"
- "8300"
- "8301"
command: "agent -config-dir=/config -server -join consul1"
depends_on:
- consul1
consul3:
image: "consul.1.0.1"
container_name: "consul3"
hostname: "consul3"
volumes:
- ./consul/config:/config/
expose:
- "8400"
- "8500"
- "8600"
- "8300"
command: "agent -config-dir=/config -server -join consul1"
depends_on:
- consul1
vault:
depends_on:
- consul1
image: "vault"
hostname: "vault"
links:
- "consul1:consul1"
environment:
VAULT_ADDR: http://127.0.0.1:8200
ports:
- "8200:8200"
volumes:
- ./vault/tools/wait-for-it.sh:/wait-for-it.sh
- ./vault/config/vault:/config
- ./vault/config/vault/policies:/policies
entrypoint: /wait-for-it.sh -t 20 -h consul1 -p 8500 -s -- vault server -config=/config/with-consul.hcl

领事设置:

{
"data_dir": "/data",
"client_addr": "0.0.0.0",
"ports": {
"dns": 53
},
"disable_update_check": true,
"addresses": {
"https": "0.0.0.0"
}
}

最佳答案

首先尝试使用单个领事实例运行并首先使其正常工作。默认情况下,docker consul 将在开发模式下运行 - 没有“bootstrap=3” - 一对一端口映射是完整的(即单个 docker 虚拟机到主机端口,不会与 consul2、consul3 复杂化):

“8400:8400”“8500:8500”“8600:53”“8300:8300”“8301:8301”

关于docker - 领事+领事代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47789724/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com