Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Docker & Docker Compose Deployment

Deploy Mir using Docker for containerized environments with flexible configuration options.

Prerequisites

Docker Compose Deployment

The Compose comes with a full production setup:

  • Mir: IoT Hub core service
  • NATS: Message broker for inter-service communication
  • InfluxDB: Time-series database for telemetry data
  • SurrealDB: General database for device metadata
  • Prometheus Stack: Monitoring and observability
    • Prometheus
    • Grafana
    • Loki
    • Promtail
    • Alertmanager

Quick Start

The easiest way to get started is to download the pre-configured Docker Compose files from the latest Mir release:

# Extract
tar -vxf mir-compose.tar.gz

# Start the complete Mir stack
cd mir-compose/local-mir-support/
docker compose up -d

# Access the server using the CLI on localhost
mir tools config edit
# contexts:
#  - name: local
#    target: nats://localhost:4222
#    webTarget: ws://localhost:9222
#    grafana: localhost:3000
mir ctx local

# Use
mir dev ls

## Stopping
docker compose down

## To stop and remove all data
docker compose down -v

# View logs
docker compose logs mir -f

Configuration

The .env file in local_mir_support/ contains the Mir version. You can modify other settings in the individual compose files as needed.

  • ls -la to see hidden files

Environment Variables

Configure Mir using environment variables with the MIR__ prefix. Nested config keys use __ as separator (e.g. mir.http.portMIR__MIR__HTTP__PORT):

VariableDescriptionDefault
MIR__MIR__LOGLEVELLogging levelinfo
MIR__MIR__HTTP__PORTCockpit HTTP port3015
MIR__MIR__HTTP__TLSCERTPath to Cockpit TLS certificate``
MIR__MIR__HTTP__TLSKEYPath to Cockpit TLS private key``
MIR__MIR__COCKPIT__ENABLEDEnable Cockpit servicetrue
MIR__MIR__CORE__ENABLEDEnable Core servicetrue
MIR__NATS__URLNATS server URLnats://localhost:4222
MIR__NATS__CREDENTIALSPath to NATS credentials file``
MIR__NATS__ROOTCAPath to NATS root CA certificate``
MIR__NATS__TLSCERTPath to NATS client certificate``
MIR__NATS__TLSKEYPath to NATS client private key``
MIR__SURREAL__URLSurrealDB WebSocket URLws://localhost:8000
MIR__SURREAL__USERSurrealDB usernameroot
MIR__SURREAL__PASSWORDSurrealDB passwordroot
MIR__SURREAL__NAMESPACESurrealDB namespaceglobal
MIR__SURREAL__DATABASESurrealDB databasemir
MIR__INFLUX__URLInfluxDB HTTP URLhttp://localhost:8086
MIR__INFLUX__TOKENInfluxDB auth token``
MIR__INFLUX__ORGInfluxDB organizationMir
MIR__INFLUX__BUCKETInfluxDB bucketmir

Configuration File

Mount a configuration file for advanced settings

Modify mir-compose/mir/local-config.yaml

mir:
  logLevel: "info"
  http:
    port: 3015
    tlsCert: "/etc/mir/certs/tls.crt"
    tlsKey: "/etc/mir/certs/tls.key"
  core:
    enabled: true
    deviceOnlineFlush: 7s
    deviceOfflineFlush: 12s
    deviceOfflineAfter: 30s
  prototlm:
    enabled: true
  protocmd:
    enabled: true
  protocfg:
    enabled: true
  event:
    enabled: true
    flushInterval: 5s
  cockpit:
    enabled: true
    allowedOrigins: []
    githubOwner: MaxThom
    githubRepo: mir
nats:
  url: "nats://local_mir_support-nats-1:4222"
  credentials: ""
  rootCA: ""
  tlsCert: ""
  tlsKey: ""
surreal:
  url: "ws://local_mir_support-surrealdb-1:8000/rpc"
  namespace: "global"
  database: "mir"
  user: "root"
  password: "root"
influx:
  url: "http://local_mir_support-influxdb-1:8086/"
  token: "mir-operator-token"
  org: "Mir"
  bucket: "mir"
  batchSize: 1000
  flushInterval: 1000
  retryBufferLimit: 1073741824
  gzip: false

Configure Cockpit Server List

Cockpit reads available contexts from ./mir-compose/mir/local-contexts.yaml (mounted into the container as cli.yaml) and exposes them to the browser via GET /api/v1/contexts. Each context entry defines a server the web UI can connect to.

Edit ./mir-compose/mir/local-contexts.yaml to list your servers:

logLevel: info
currentContext: local
contexts:
  - name: local
    target: nats://localhost:4222
    webTarget: ws://localhost:9222
    grafana: localhost:3000

Restart to apply: docker compose down && docker compose up.

Operating

Port Exposures

# Cockpit
localhost:3015
# Grafana       <user>///<password>
localhost:3000 # admin///mir-operator
# InfluxDB
localhost:8086 # admin///mir-operator
# SurrealDB
localhost:8000 # root///root
# Prometheus
localhost:9090
# NatsIO
localhost:4222 # TCP
localhost:9222 # WebSocket

View Logs

# in mir-compose/local-mir-support/
# View Mir logs
docker compose logs mir

# Follow logs in real-time
docker compose logs -f mir

Multi-Architecture Support

Mir Docker images support multiple architectures:

  • linux/amd64: Intel/AMD 64-bit
  • linux/arm64: ARM 64-bit
  • linux/arm32: ARM 32-bit

Docker automatically selects the appropriate architecture.

Security

Securing the environment is done via the NSC tool. Refer to Docker Authentication for details.

Next Steps

  • Configure devices to connect to your Mir instance
  • Set up monitoring dashboards in Grafana
  • Review Kubernetes deployment for production scale
  • Explore the Mir CLI for management