version: '3.8' services: consul: image: consul:latest hostname: consul-master command: > sh -c " IP=$$(hostname -i | awk '{print $$1}'); consul agent -server -bootstrap-expect=2 -datacenter=dc1 -data-dir=/consul/data -node=consul-master -bind=$$IP -advertise=100.117.106.136 -client=0.0.0.0 -ui -log-level=INFO " ports: - "8500:8500" - "8600:8600/udp" volumes: - consul_data:/consul/data networks: - consul-net deploy: mode: replicated replicas: 1 placement: constraints: - node.hostname == master restart_policy: condition: on-failure delay: 5s max_attempts: 3 volumes: consul_data: networks: consul-net: driver: overlay attachable: true