diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 02765c0..d67bf73 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -4,7 +4,7 @@ services: container_name: rustfs_container restart: always ports: - - 100.64.0.5:9000:9000 + - 100.64.0.42:9000:9000 volumes: - /vol2/1000/rustfs_vol2:/data - ./data:/app/data:rw # 新增,共用 ./data @@ -26,44 +26,62 @@ services: volumes: - ./data:/app/data:rw ports: - - "100.64.0.5:9009:9009" + - "100.64.0.42:9009:9009" consul-agent: + stop_signal: SIGTERM + stop_grace_period: 30s image: hashicorp/consul:1.21 - command: > - agent - -client=0.0.0.0 - -bind=100.64.0.5 - -advertise=100.64.0.5 - -data-dir=/consul/data - -retry-join=100.64.0.1 - -datacenter=dc1 - # network_mode: "host" # 避免 8301/udp 等端口映射问题 - volumes: - - /var/lib/consul:/consul/data + command: + - agent + - -server=false + - -node=rustfs-100-64-0-42 + - -client=0.0.0.0 + - -bind=0.0.0.0 + - -advertise=100.64.0.42 + - -retry-join=100.64.0.1 + - -datacenter=dc1 + - -data-dir=/consul/data + environment: + CONSUL_LOCAL_CONFIG: '{"leave_on_terminate": true}' + ports: + - "100.64.0.42:8500:8500/tcp" + - "100.64.0.42:8600:8600/tcp" + - "100.64.0.42:8600:8600/udp" + - "100.64.0.42:8301:8301/tcp" + - "100.64.0.42:8301:8301/udp" healthcheck: - test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:8500/v1/agent/self >/dev/null"] - interval: 3s - timeout: 2s - retries: 60 + test: ["CMD", "consul", "info"] + interval: 5s + timeout: 3s + retries: 30 + start_period: 10s restart: unless-stopped registrar: image: hashicorp/consul:1.21 - network_mode: "host" depends_on: consul-agent: condition: service_healthy - rustfs-s3-toolkit: + rustfs: condition: service_started environment: - - SERVICE_NAME=rustfs - - SERVICE_ADDR=100.64.0.5 - - SERVICE_PORT=9000 - - CONSUL_HTTP_ADDR=http://127.0.0.1:8500 + CONSUL_HTTP_ADDR: "http://consul-agent:8500" + SERVICE_NAME: "rustfs" + SERVICE_ADDR: "100.64.0.42" + SERVICE_PORT: "9000" + # 可选:打标签,方便 SRV 过滤 + SERVICE_TAGS: "console" + # 健康检查参数(可按需改) + CHECK_TYPE: "tcp" # 可选: "http" 或 "tcp" + CHECK_PATH: "/healthz" # 仅 http 模式用 + CHECK_INTERVAL: "10s" + CHECK_TIMEOUT: "2s" + DEREG_AFTER: "1m" # 持续失败 1 分钟后自动从 Catalog 摘除 volumes: - ./registrar.sh:/registrar.sh:ro entrypoint: ["/bin/sh","-lc","/registrar.sh"] restart: unless-stopped + networks: {} \ No newline at end of file