原文链接:https://www.zhoubotong.site/post/77.html
安装docker-compose这里就不介绍了,直接进入正题:
创建etcd数据目录(根据需要可自行修改)
mkdir -p /app/download/etcd/data
切换到自定义目录(如我的是/media/uos/Roota/edcd-server),新建docker-compose.yaml
version: "3.5"
services:
etcd:
hostname: etcd
image: bitnami/etcd:latest
deploy:
replicas: 1
restart\_policy:
condition: on-failure
privileged: true
volumes:
- "/app/download/etcd/data:/bitnami/etcd"# 注意这个目录容器要可写,不然会报cannot access data directory: open
environment:
- "ETCD\_ADVERTISE\_CLIENT\_URLS=http://0.0.0.0:2379"
- "ETCD\_LISTEN\_CLIENT\_URLS=http://0.0.0.0:2379"
- "ETCD\_LISTEN\_PEER\_URLS=http://0.0.0.0:2380"
- "ETCD\_INITIAL\_ADVERTISE\_PEER\_URLS=http://0.0.0.0:2380"
- "ALLOW\_NONE\_AUTHENTICATION=yes" #参数指不用密码可以连接
- "ETCD\_INITIAL\_CLUSTER=node1=http://0.0.0.0:2380"
- "ETCD\_NAME=node1"
- "ETCD\_DATA\_DIR=/opt/bitnami/etcd/data"
ports:
- 2379:2379
- 2380:2380
networks:
- myetcdnet
networks:
myetcdnet:
name: myetcdnet
启动、停止etcd
uos@uos-PC:/media/uos/Roota/edcd-server$ docker compose up -d
uos@uos-PC:/media/uos/Roota/edcd-server$ docker compose down
安装etcd可视化工具etcdkeeper
docker run -it -d --name etcdkeeper \\-p 8080:8080 \\
deltaprojects/etcdkeeper
暂时没有数据,后面再补下compose部署集群,使用golang连接etcd。> >
标签:uos,compose,etcd,部署,0.0,ETCD,docker From: https://www.cnblogs.com/phpper/p/16630937.html