docker 安装consul
时间: 2023-10-06 17:11:57 浏览: 247
要在Docker上安装Consul,可以按照以下步骤进行操作:
1. 执行命令拉取最新版本的Consul镜像:
`docker pull consul:1.4.4`
2. 创建第一台Consul服务器节点,并将其设置为leader:
```
docker run -d -p 8500:8500 \
-v /docker/consul/data/server1:/docker/consul/data \
-v /docker/consul/conf/server1:/docker/consul/conf \
-h=node1 --net=host \
-e CONSUL_BIND_INTERFACE=ens33 \
--privileged=true \
--name consul_server_1 \
consul:1.4.4 agent \
-bind=192.168.48.128 \
-server=true -bootstrap-expect=3 -ui \
-node=consul_server_1 -client='0.0.0.0' \
-datacenter=xdp_dc \
-data-dir /docker/consul/data/ \
-config-dir /docker/consul/conf/
```
3. 查看集群成员:
`docker exec -it consul_name consul members`
4. 建立最后一个Consul节点:
`docker run -d --name consul-03 -e CONSUL_BIND_INTERFACE=eth0 docker.io/consul:latest agent -server -join 172.17.0.1`
这样,你就成功地在Docker上安装了Consul。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Docker安装consul](https://blog.csdn.net/weixin_41753567/article/details/124422431)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [【微服务| Consul】使用docker搭建consul集群](https://blog.csdn.net/weixin_42216109/article/details/125794468)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文