Skip to main content
Deploy MQTT Gateway using Docker for consistent, isolated environments across different systems.

Prerequisites

  • Docker installed and running
  • Access to a MariaDB instance
  • Access to an MQTT broker
  • Network connectivity between containers and external services

Build the Docker image

1

Build the image

Build the Docker image from the project root:
The Dockerfile uses Python 3.12-slim as the base image and installs all dependencies from requirements.txt:
2

Verify the image

Confirm the image was built successfully:

Run the container

1

Create log directory

Create a directory on the host to persist logs:
2

Run with environment variables

Run the container with required environment variables:

Environment variables

Configure the gateway using these environment variables:

Volume mounts

The container requires one volume mount for persistent logs:
This mounts the host’s ./log directory to /app/log inside the container, ensuring logs persist after the container stops.

Network configuration

Ensure the Docker container can reach both the MariaDB database and MQTT broker. If running on a custom Docker network, use the --network flag.

Connect to existing network

Run in background

Run the container as a daemon using the -d flag:
The --restart unless-stopped policy ensures the container restarts automatically if it crashes.

View logs

View container logs using Docker commands:
Application error logs are written to the mounted volume at ./log/YYYY-MM-DD.log.

Stop the container

If running with --rm, the container is automatically removed when stopped. Otherwise, remove it manually: