docker 部署 consul

docker 部署 consul

单节点

docker-compose.yml 示例:

1
2
3
4
5
6
7
8
9
version: '3.7'

services:
  consul:
    image: consul
    # restart: always
    ports:
      - "8500:8500"
    command: "agent -server -client 0.0.0.0 -bootstrap -node consul1 -ui -bind 0.0.0.0"

多节点

docker-compose.yml 示例:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
version: '3.7'

services:
  consul1:
    image: consul
    # restart: always
    ports:
      - "8500:8500"
    command: "agent -server -client 0.0.0.0 -bootstrap-expect 3 -node consul1 -ui -bind 0.0.0.0"

  consul2:
    image: consul
    # restart: always
    command: "agent -server -client 0.0.0.0 -retry-join=consul1 -node consul2 -bind 0.0.0.0"

  consul3:
    image: consul
    # restart: always
    command: "agent -server -client 0.0.0.0 -retry-join=consul1 -node consul3 -bind 0.0.0.0"