docker.recipes

EMQX

intermediate

Scalable MQTT broker for IoT.

Overview

EMQX is a high-performance, open-source MQTT broker designed specifically for IoT and real-time messaging applications. Originally developed by EMQ Technologies, EMQX has evolved into one of the most scalable MQTT brokers available, capable of handling millions of concurrent connections while maintaining low latency and high throughput. Built on Erlang/OTP, it leverages the actor model for exceptional fault tolerance and distributed computing capabilities. This Docker deployment provides a complete EMQX broker instance with multiple protocol endpoints and a comprehensive web dashboard for monitoring and management. The configuration exposes standard MQTT ports (1883), secure MQTT over SSL (8883), WebSocket connections (8083/8084), and the administrative dashboard (18083), making it suitable for both development and production IoT environments. EMQX excels in scenarios requiring massive device connectivity, real-time data streaming, and complex message routing rules. The broker's built-in rule engine allows for real-time data processing and transformation without requiring external components. This makes EMQX particularly valuable for IoT platform developers, industrial automation companies, and organizations building large-scale device management systems where message reliability and horizontal scalability are critical requirements.

Key Features

  • Massive concurrent connection support with millions of MQTT clients per node
  • Built-in rule engine for real-time message processing, filtering, and transformation
  • Multiple protocol support including MQTT 3.1.1, MQTT 5.0, WebSocket, and CoAP
  • Hot configuration updates without service interruption or connection drops
  • Advanced authentication and authorization with JWT, OAuth 2.0, and custom plugins
  • Message persistence and replay capabilities for reliable delivery guarantees
  • Comprehensive monitoring and alerting through built-in metrics and webhook notifications
  • Plugin architecture supporting custom extensions for databases, message queues, and cloud services

Common Use Cases

  • 1IoT device management platforms requiring high-volume sensor data collection
  • 2Industrial automation systems with real-time machine-to-machine communication
  • 3Smart city infrastructure connecting traffic lights, environmental sensors, and public displays
  • 4Vehicle telematics platforms tracking fleet location, diagnostics, and driver behavior
  • 5Home automation hubs managing smart thermostats, security cameras, and lighting systems
  • 6Real-time chat applications and mobile push notification services
  • 7Financial trading platforms requiring low-latency market data distribution

Prerequisites

  • Minimum 2GB RAM for basic deployment, 4GB+ recommended for production workloads
  • Available ports 1883, 8083, 8084, 8883, and 18083 on the host system
  • Basic understanding of MQTT protocol concepts and publish/subscribe messaging patterns
  • Familiarity with SSL certificate management for secure MQTT connections
  • Network configuration knowledge for firewall rules and load balancer setup
  • Understanding of IoT device authentication methods and connection security

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 emqx:
3 image: emqx/emqx:latest
4 container_name: emqx
5 restart: unless-stopped
6 environment:
7 EMQX_NAME: emqx
8 EMQX_HOST: 127.0.0.1
9 volumes:
10 - emqx_data:/opt/emqx/data
11 - emqx_log:/opt/emqx/log
12 ports:
13 - "1883:1883"
14 - "8083:8083"
15 - "8084:8084"
16 - "8883:8883"
17 - "18083:18083"
18
19volumes:
20 emqx_data:
21 emqx_log:

.env Template

.env
1# Default dashboard: admin / public

Usage Notes

  1. 1Docs: https://www.emqx.io/docs/
  2. 2Dashboard at http://localhost:18083, default: admin/public
  3. 3MQTT on 1883, MQTT/SSL on 8883, WebSocket on 8083/8084
  4. 4Supports millions of concurrent connections
  5. 5Built-in rule engine for data processing
  6. 6Enterprise features: clustering, bridges, integrations

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 emqx:
5 image: emqx/emqx:latest
6 container_name: emqx
7 restart: unless-stopped
8 environment:
9 EMQX_NAME: emqx
10 EMQX_HOST: 127.0.0.1
11 volumes:
12 - emqx_data:/opt/emqx/data
13 - emqx_log:/opt/emqx/log
14 ports:
15 - "1883:1883"
16 - "8083:8083"
17 - "8084:8084"
18 - "8883:8883"
19 - "18083:18083"
20
21volumes:
22 emqx_data:
23 emqx_log:
24EOF
25
26# 2. Create the .env file
27cat > .env << 'EOF'
28# Default dashboard: admin / public
29EOF
30
31# 3. Start the services
32docker compose up -d
33
34# 4. View logs
35docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/emqx/run | bash

Troubleshooting

  • Connection refused on port 1883: Verify the container is running and port mapping is correct with 'docker ps'
  • Dashboard shows 'admin/public' login failure: Reset credentials using 'docker exec emqx emqx_ctl admins passwd admin newpassword'
  • High memory usage with many connections: Increase Docker memory limits and tune EMQX connection pool settings
  • SSL/TLS handshake failures on port 8883: Check certificate validity and ensure proper SSL configuration in EMQX settings
  • Message delivery delays under load: Adjust EMQX message queue limits and enable message persistence for better throughput
  • WebSocket connection timeouts: Configure proxy timeout settings and check for network connectivity issues between clients and port 8083/8084

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space