Docker部署单节点etcd
docker-compose.yml
version: "3.5"
services:
etcd:
hostname: etcd
image: bitnami/etcd:3
deploy:
replicas: 1
restart_policy:
condition: on-failure
# ports:
# - "2379:2379"
# - "2380:2380"
# - "4001:4001"
# - "7001:7001"
privileged: true
volumes:
- "/etcd/data:/opt/bitnami/etcd/data"
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:
- etcdnet
networks:
etcdnet:
name: etcdnet
- 在任一目录下创建
docker-compose.yml
文件 - 创建
/etcd/data
目录,用来映射目录存储etcd
的数据 - 访问
2379
端口即可
启动命令
docker-compose up
在docker-compose.yml
所在目录下执行即可,会在Docker创建容器后续就不需要这样来
网友评论