docker desktop 安装etcd
时间: 2023-09-06 16:10:02 浏览: 183
要在docker desktop上安装etcd,可以按照以下步骤进行操作:
1. 首先,创建一个目录来存储etcd的数据文件,可以将其命名为`/usr/local/docker/etcd`。
2. 在该目录下创建一个名为`docker-compose.yml`的文件,并在其中添加以下内容:
```yaml
version: '3'
networks:
myetcd_cluster:
services:
etcd1:
image: quay.io/coreos/etcd
container_name: etcd1
command: etcd -name etcd1 -advertise-client-urls http://0.0.0.0:2379 -listen-client-urls http://0.0.0.0:2379 -listen-peer-urls http://0.0.0.0:2380
ports:
- 12379:2379
- 12380:2380
volumes:
- ./etcd1:/etcd-data
networks:
- myetcd_cluster
etcd2:
image: quay.io/coreos/etcd
container_name: etcd2
command: etcd -name etcd2 -advertise-client-urls http://0.0.0.0:2379 -listen-client-urls http://0.0.0.0:2379 -listen-peer-urls http://0.0.0.0:2380 -initial-advertise-peer-urls http://etcd1:2380
volumes:
- ./etcd2:/etcd-data
networks:
- myetcd_cluster
etcd3:
image: quay.io/coreos/etcd
container_name: etcd3
command: etcd -name etcd3 -advertise-client-urls http://0.0.0.0:2379 -listen-client-urls http://0.0.0.0:2379 -listen-peer-urls http://0.0.0.0:2380 -initial-advertise-peer-urls http://etcd1:2380
volumes:
- ./etcd3:/etcd-data
networks:
- myetcd_cluster
```
3. 运行以下命令启动etcd集群:
```bash
docker-compose up -d
```
这将在后台启动etcd集群。现在,您可以使用etcd客户端工具来与etcd集群进行交互。
请注意,上述步骤假设您已经安装了docker desktop,并且已经将其正确配置。确保在进行上述步骤之前先安装和配置docker desktop。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [ETCD教程(一) 通过docker安装etcd集群](https://blog.csdn.net/JineD/article/details/127290804)[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^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文