docker-compose

    1. version: '2'
    2. services:
    3. consul_server_1:
    4. image: "consul:latest"
    5. container_name: "consul_server_1"
    6. environment:
    7. CONSUL_LOCAL_CONFIG: '{"leave_on_terminate": true}'
    8. networks:
    9. app_net:
    10. ipv4_address: 172.17.0.3
    11. command: "agent -server -bind=172.17.0.3 -client=172.17.0.3 -retry-join=172.17.0.2"
    12. consul_server_2:
    13. image: "consul:latest"
    14. container_name: "consul_server_2"
    15. ports:
    16. - "8600:8600"
    17. - "8500:8500"
    18. networks:
    19. app_net:
    20. ipv4_address: 172.17.0.4
    21. command: "agent -server -bind=172.17.0.4 -client=172.17.0.4 -retry-join=172.17.0.3 -ui"
    22. consul_server_3:
    23. image: "consul:latest"
    24. container_name: "consul_server_3"
    25. environment:
    26. CONSUL_LOCAL_CONFIG: '{"leave_on_terminate": true}'
    27. networks:
    28. app_net:
    29. ipv4_address: 172.17.0.5
    30. command: "agent -server -bind=172.17.0.5 -client=172.17.0.5 -retry-join=172.17.0.4 -bootstrap-expect=3"
    31. networks:
    32. app_net:
    33. driver: bridge
    34. ipam:
    35. config:
    36. - subnet: 172.17.0.0/24
    1. $ docker-compose up -d