Docker-单节点单Etcd部署
数据目录
mkdir /data/docker/etcd/data -p
docker-compose.yaml
version: "3.7"
services:
etcd:
image: "bitnami/etcd:3.5"
container_name: "etcd"
# 总是重启
restart: "always"
ports:
- 2379:2379
environment:
# 时区设置
- TZ=Asia/Shanghai
# 允许无认证访问
- ALLOW_NONE_AUTHENTICATION=yes
# etcd 客户端访问URL
- ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379
volumes:
# 将数据映射到宿主机
- etcd_data:/bitnami/etcd
volumes:
etcd_data:
driver: local
driver_opts:
type: "none"
o: "bind"
device: "/data/docker/etcd/data"
简单使用
[root@VM-0-14-centos ~]# curl localhost:2379/version
{"etcdserver":"3.5.10","etcdcluster":"3.5.0"}
[root@VM-0-14-centos ~]# docker exec -it etcd /bin/sh -c "etcdctl put /k v"
OK
[root@VM-0-14-centos ~]# docker exec -it etcd /bin/sh -c "etcdctl get /k"
/k
v
Last updated