docker.recipes

Zabbix Monitoring Stack

intermediate

Zabbix monitoring with PostgreSQL and web frontend.

Overview

Zabbix is an enterprise-class open-source monitoring solution that has been actively developed since 2001, designed to monitor networks, servers, virtual machines, and cloud services. It provides real-time monitoring, alerting, and visualization capabilities with support for thousands of devices and metrics, making it a comprehensive infrastructure monitoring platform used by organizations worldwide. This deployment creates a complete Zabbix monitoring environment using four interconnected containers: a PostgreSQL database for storing configuration and metrics data, the Zabbix server daemon for data collection and processing, a web frontend with embedded Nginx for the user interface, and a Zabbix agent for monitoring the Docker host itself. The stack uses PostgreSQL as the backend database, providing robust data integrity and performance for storing the extensive monitoring data that Zabbix collects. This configuration is ideal for system administrators and DevOps teams who need a professional-grade monitoring solution that can scale from small environments to enterprise infrastructures, offering both agentless and agent-based monitoring with flexible alerting mechanisms and comprehensive reporting capabilities.

Key Features

  • Real-time monitoring with customizable data collection intervals from seconds to hours
  • Multi-tier alerting system with escalation policies and multiple notification channels
  • Template-based configuration system for rapid deployment of monitoring across similar hosts
  • Network discovery capabilities for automatic detection and monitoring of network devices
  • Built-in graphing engine with trend analysis and forecasting functions
  • Low-level discovery rules for automatic monitoring of dynamic resources like filesystems and network interfaces
  • Web-based administration interface with role-based access control and user management
  • PostgreSQL backend providing ACID compliance and efficient storage of time-series monitoring data

Common Use Cases

  • 1Enterprise infrastructure monitoring across physical, virtual, and cloud environments
  • 2Network operations center (NOC) deployments requiring centralized monitoring dashboards
  • 3DevOps teams implementing comprehensive observability for application and infrastructure stacks
  • 4Managed service providers offering monitoring services to multiple clients with tenant isolation
  • 5IT departments transitioning from legacy monitoring tools to a unified open-source solution
  • 6Compliance-driven environments requiring detailed audit trails and performance documentation
  • 7High-availability service monitoring with automatic failover detection and alerting

Prerequisites

  • Docker and Docker Compose installed with at least 2GB available RAM for optimal performance
  • Port 8080 available for web interface and port 10051 for Zabbix server communication
  • Basic understanding of monitoring concepts like hosts, items, triggers, and templates
  • Network access from monitored systems to the Zabbix server on port 10051
  • Understanding of PostgreSQL basics for database maintenance and backup procedures
  • Familiarity with SNMP, SSH, or agent-based monitoring depending on your target systems

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 postgres:
3 image: postgres:16-alpine
4 container_name: zabbix-postgres
5 restart: unless-stopped
6 environment:
7 POSTGRES_USER: ${POSTGRES_USER:-zabbix}
8 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-zabbix}
9 POSTGRES_DB: ${POSTGRES_DB:-zabbix}
10 volumes:
11 - postgres_data:/var/lib/postgresql/data
12 networks:
13 - zabbix-network
14
15 zabbix-server:
16 image: zabbix/zabbix-server-pgsql:latest
17 container_name: zabbix-server
18 restart: unless-stopped
19 ports:
20 - "10051:10051"
21 environment:
22 - DB_SERVER_HOST=postgres
23 - POSTGRES_USER=${POSTGRES_USER:-zabbix}
24 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-zabbix}
25 - POSTGRES_DB=${POSTGRES_DB:-zabbix}
26 depends_on:
27 - postgres
28 networks:
29 - zabbix-network
30
31 zabbix-web:
32 image: zabbix/zabbix-web-nginx-pgsql:latest
33 container_name: zabbix-web
34 restart: unless-stopped
35 ports:
36 - "${WEB_PORT:-8080}:8080"
37 environment:
38 - DB_SERVER_HOST=postgres
39 - POSTGRES_USER=${POSTGRES_USER:-zabbix}
40 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-zabbix}
41 - POSTGRES_DB=${POSTGRES_DB:-zabbix}
42 - ZBX_SERVER_HOST=zabbix-server
43 - PHP_TZ=${TZ:-UTC}
44 depends_on:
45 - postgres
46 - zabbix-server
47 networks:
48 - zabbix-network
49
50 zabbix-agent:
51 image: zabbix/zabbix-agent:latest
52 container_name: zabbix-agent
53 restart: unless-stopped
54 environment:
55 - ZBX_SERVER_HOST=zabbix-server
56 depends_on:
57 - zabbix-server
58 networks:
59 - zabbix-network
60
61volumes:
62 postgres_data:
63
64networks:
65 zabbix-network:
66 driver: bridge

.env Template

.env
1# Zabbix
2WEB_PORT=8080
3POSTGRES_USER=zabbix
4POSTGRES_PASSWORD=zabbix
5POSTGRES_DB=zabbix
6TZ=UTC

Usage Notes

  1. 1Zabbix at http://localhost:8080
  2. 2Default login: Admin/zabbix
  3. 3Change password on first login
  4. 4Deploy agents on monitored hosts

Individual Services(4 services)

Copy individual services to mix and match with your existing compose files.

postgres
postgres:
  image: postgres:16-alpine
  container_name: zabbix-postgres
  restart: unless-stopped
  environment:
    POSTGRES_USER: ${POSTGRES_USER:-zabbix}
    POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-zabbix}
    POSTGRES_DB: ${POSTGRES_DB:-zabbix}
  volumes:
    - postgres_data:/var/lib/postgresql/data
  networks:
    - zabbix-network
zabbix-server
zabbix-server:
  image: zabbix/zabbix-server-pgsql:latest
  container_name: zabbix-server
  restart: unless-stopped
  ports:
    - "10051:10051"
  environment:
    - DB_SERVER_HOST=postgres
    - POSTGRES_USER=${POSTGRES_USER:-zabbix}
    - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-zabbix}
    - POSTGRES_DB=${POSTGRES_DB:-zabbix}
  depends_on:
    - postgres
  networks:
    - zabbix-network
zabbix-web
zabbix-web:
  image: zabbix/zabbix-web-nginx-pgsql:latest
  container_name: zabbix-web
  restart: unless-stopped
  ports:
    - ${WEB_PORT:-8080}:8080
  environment:
    - DB_SERVER_HOST=postgres
    - POSTGRES_USER=${POSTGRES_USER:-zabbix}
    - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-zabbix}
    - POSTGRES_DB=${POSTGRES_DB:-zabbix}
    - ZBX_SERVER_HOST=zabbix-server
    - PHP_TZ=${TZ:-UTC}
  depends_on:
    - postgres
    - zabbix-server
  networks:
    - zabbix-network
zabbix-agent
zabbix-agent:
  image: zabbix/zabbix-agent:latest
  container_name: zabbix-agent
  restart: unless-stopped
  environment:
    - ZBX_SERVER_HOST=zabbix-server
  depends_on:
    - zabbix-server
  networks:
    - zabbix-network

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 postgres:
5 image: postgres:16-alpine
6 container_name: zabbix-postgres
7 restart: unless-stopped
8 environment:
9 POSTGRES_USER: ${POSTGRES_USER:-zabbix}
10 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-zabbix}
11 POSTGRES_DB: ${POSTGRES_DB:-zabbix}
12 volumes:
13 - postgres_data:/var/lib/postgresql/data
14 networks:
15 - zabbix-network
16
17 zabbix-server:
18 image: zabbix/zabbix-server-pgsql:latest
19 container_name: zabbix-server
20 restart: unless-stopped
21 ports:
22 - "10051:10051"
23 environment:
24 - DB_SERVER_HOST=postgres
25 - POSTGRES_USER=${POSTGRES_USER:-zabbix}
26 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-zabbix}
27 - POSTGRES_DB=${POSTGRES_DB:-zabbix}
28 depends_on:
29 - postgres
30 networks:
31 - zabbix-network
32
33 zabbix-web:
34 image: zabbix/zabbix-web-nginx-pgsql:latest
35 container_name: zabbix-web
36 restart: unless-stopped
37 ports:
38 - "${WEB_PORT:-8080}:8080"
39 environment:
40 - DB_SERVER_HOST=postgres
41 - POSTGRES_USER=${POSTGRES_USER:-zabbix}
42 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-zabbix}
43 - POSTGRES_DB=${POSTGRES_DB:-zabbix}
44 - ZBX_SERVER_HOST=zabbix-server
45 - PHP_TZ=${TZ:-UTC}
46 depends_on:
47 - postgres
48 - zabbix-server
49 networks:
50 - zabbix-network
51
52 zabbix-agent:
53 image: zabbix/zabbix-agent:latest
54 container_name: zabbix-agent
55 restart: unless-stopped
56 environment:
57 - ZBX_SERVER_HOST=zabbix-server
58 depends_on:
59 - zabbix-server
60 networks:
61 - zabbix-network
62
63volumes:
64 postgres_data:
65
66networks:
67 zabbix-network:
68 driver: bridge
69EOF
70
71# 2. Create the .env file
72cat > .env << 'EOF'
73# Zabbix
74WEB_PORT=8080
75POSTGRES_USER=zabbix
76POSTGRES_PASSWORD=zabbix
77POSTGRES_DB=zabbix
78TZ=UTC
79EOF
80
81# 3. Start the services
82docker compose up -d
83
84# 4. View logs
85docker 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/zabbix-monitoring/run | bash

Troubleshooting

  • Zabbix server container fails to start: Check PostgreSQL container is healthy and database credentials match between postgres and zabbix-server services
  • Web interface shows database connection errors: Verify POSTGRES_USER, POSTGRES_PASSWORD, and POSTGRES_DB environment variables are consistent across zabbix-web and postgres services
  • Cannot access web interface at localhost:8080: Ensure WEB_PORT environment variable is set correctly and no other service is using the configured port
  • Zabbix agent not appearing in web interface: Check that zabbix-agent container can resolve zabbix-server hostname and verify ZBX_SERVER_HOST environment variable
  • High memory usage in postgres container: Monitor postgres_data volume size and implement data housekeeping policies in Zabbix administration settings
  • Zabbix server reports database connection timeouts: Increase PostgreSQL max_connections setting and ensure adequate resources are allocated to postgres container

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