version: "3"
services:
  etcd1:
    image: quay.io/coreos/etcd:v3.5.0  # 镜像
    container_name: etcd1       
    restart: always            
    networks:
      - etcd-net               
    ports:                    
      - "20000:2379"
      - "20001:2380"
    environment:            
      - ALLOW_NONE_AUTHENTICATION=yes                       
      - ETCD_NAME=etcd1                                     
      - ETCD_INITIAL_ADVERTISE_PEER_URLS=http://etcd1:2380  
      - ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380          
      - ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379         
      - ETCD_ADVERTISE_CLIENT_URLS=http://etcd1:2379       
      - ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster             
      - ETCD_INITIAL_CLUSTER=etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380
      - ETCD_INITIAL_CLUSTER_STATE=new                  
      - ETCDCTL_API=3                                      
    volumes:
      - /etc/localtime:/etc/localtime

  etcd2:
    image: quay.io/coreos/etcd:v3.5.0
    container_name: etcd2
    restart: always
    networks:
      - etcd-net
    ports:
      - "20002:2379"
      - "20003:2380"
    environment:
      - ALLOW_NONE_AUTHENTICATION=yes
      - ETCD_NAME=etcd2
      - ETCD_INITIAL_ADVERTISE_PEER_URLS=http://etcd2:2380
      - ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380
      - ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
      - ETCD_ADVERTISE_CLIENT_URLS=http://etcd2:2379
      - ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster
      - ETCD_INITIAL_CLUSTER=etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380
      - ETCD_INITIAL_CLUSTER_STATE=new
      - ETCDCTL_API=3
    volumes:
      - /etc/localtime:/etc/localtime
      
  etcd3:
    image: quay.io/coreos/etcd:v3.5.0
    container_name: etcd3
    restart: always
    networks:
      - etcd-net
    ports:
      - "20004:2379"
      - "20005:2380"
    environment:
      - ALLOW_NONE_AUTHENTICATION=yes
      - ETCD_NAME=etcd3
      - ETCD_INITIAL_ADVERTISE_PEER_URLS=http://etcd3:2380
      - ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380
      - ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
      - ETCD_ADVERTISE_CLIENT_URLS=http://etcd3:2379
      - ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster
      - ETCD_INITIAL_CLUSTER=etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380
      - ETCD_INITIAL_CLUSTER_STATE=new
      - ETCDCTL_API=3
    volumes:
      - /etc/localtime:/etc/localtime

networks:
  etcd-net:           
    driver: bridge    
