Skip to content

Docker 部署

  • 目前 FreeMQTT Plus 只提供Linux下的 Docker 镜像部署方式
  • 我们提供了在单机上部署 FreeMQTT Plus 的 docker-compose yaml 文件
  • 只需:$ sudo docker-compose up -d 便可启动 FreeMQTT Plus 集群
  • 可以用 docker swarm 或 k8s 在多主机上部署

启动脚本 docker-compose.yml

yaml
version: '3'
networks:
  bus:
    driver: bridge

services:
  freemqtt_log:
    image: freemqttplus:latest
    container_name: fmq-log
    restart: unless-stopped
    volumes:
      - "/etc/localtime:/etc/localtime:ro"
      - "./conf.d:/freemqttd/conf.d:ro"
      - "./log:/freemqttd/log"
    command: ["--type=L", "--nodeid=L1"]
    networks:
      - bus

  freemqtt_a1:
    image: freemqttplus:latest
    container_name: fmq-a1
    restart: unless-stopped
    volumes:
      - "/etc/localtime:/etc/localtime:ro"
      - "./conf.d:/freemqttd/conf.d:ro"
    command: ["--type=A", "--nodeid=A1"]
    depends_on:
      - freemqtt_log
    networks:
      - bus

  freemqtt_a2:
    image: freemqttplus:latest
    container_name: fmq-a2
    restart: unless-stopped
    volumes:
      - "/etc/localtime:/etc/localtime:ro"
      - "./conf.d:/freemqttd/conf.d:ro"
    command: ["--type=A", "--nodeid=A2"]
    depends_on:
      - freemqtt_log

    networks:
      - bus

  freemqtt_a3:
    image: freemqttplus:latest
    container_name: fmq-a3
    restart: unless-stopped
    volumes:
      - "/etc/localtime:/etc/localtime:ro"
      - "./conf.d:/freemqttd/conf.d:ro"
    command: ["--type=A", "--nodeid=A3"]
    depends_on:
      - freemqtt_log
    networks:
      - bus

  freemqtt_b1:
    image: freemqttplus:latest
    container_name: fmq-b1
    restart: unless-stopped
    volumes:
      - "/etc/localtime:/etc/localtime:ro"
      - "./conf.d:/freemqttd/conf.d:ro"
    ports:
      - "9201:9200"
    command: ["--type=B", "--nodeid=B1"]
    networks:
      - bus
    depends_on:
      - freemqtt_a1
      - freemqtt_a2
      - freemqtt_a3

  freemqtt_b2:
    image: freemqttplus:latest
    container_name: fmq-b2
    restart: unless-stopped
    volumes:
      - "/etc/localtime:/etc/localtime:ro"
      - "./conf.d:/freemqttd/conf.d:ro"
    ports:
      - "9202:9200"
    command: ["--type=B", "--nodeid=B2"]
    networks:
      - bus
    depends_on:
      - freemqtt_a1
      - freemqtt_a2
      - freemqtt_a3

  nginx:
    image: nginx:latest
    container_name: nginx
    restart: unless-stopped
    volumes:
      - "/etc/localtime:/etc/localtime:ro"
      - "./nginx:/etc/nginx:ro"
    ports:
      - "1883:1883"
      - "8883:8883"
      - "8080:80"
      - "8443:443"

    networks:
      - bus