docker-compose 部署consul

216 阅读1分钟

编写docker-compose.yml

version: '2.3'

services:
  consul-server:
    image: consul:1.15.4
    ports:
      - "8500:8500"
      - "8600:8600/udp"
    volumes:
      - ./consul/config:/consul/config
      - ./consul/data:/consul/data
      - ./consul/logs:/consul/logs
    command: consul agent -server -client 0.0.0.0 -ui -data-dir=/consul/data -bootstrap-expect=1
    logging:
      driver: json-file
      options:
        max-size: "200k"
        max-file: "10"
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:8500" ]
      interval: 1m30s
      timeout: 10s
      retries: 3
      start_period: 40s
    restart: always

启动

# 后台启动
docker-compose up -d
# 查看启动日志
docker-compose logs -f