docker-consul.yml 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. version: "3.7"
  2. #docker network create -d overlay --attachable client-net
  3. networks:
  4. client-net:
  5. external: true
  6. volumes:
  7. consul-data:
  8. services:
  9. consul:
  10. image: consul:1.4.0
  11. # will be used as consul node name (alphanum and dash only)
  12. hostname: "{{.Node.Hostname}}"
  13. # ports:
  14. # - target: 8500
  15. # published: 8500
  16. # mode: host
  17. command: "agent -server -retry-join consul.server -ui -client 0.0.0.0"
  18. environment:
  19. - CONSUL_BIND_INTERFACE=eth0
  20. - 'CONSUL_LOCAL_CONFIG={
  21. "datacenter":"client",
  22. "leave_on_terminate": true,
  23. "skip_leave_on_interrupt": true,
  24. "autopilot": {
  25. "cleanup_dead_servers": true
  26. },
  27. "bootstrap_expect": 2,
  28. "disable_update_check": true,
  29. "disable_host_node_id": true
  30. }'
  31. networks:
  32. client-net:
  33. aliases:
  34. - consul.server
  35. deploy:
  36. mode: global
  37. endpoint_mode: dnsrr
  38. update_config:
  39. parallelism: 1
  40. failure_action: rollback
  41. delay: 30s
  42. restart_policy:
  43. condition: any
  44. delay: 5s
  45. window: 120s
  46. volumes:
  47. - consul-data:/consul/data
  48. labels:
  49. - "SERVICE_IGNORE=yes"