This guide uses Docker Compose to run Zabbix with PostgreSQL database and web interface.
For Docker installation, see Docker.
mkdir -p /opt/zabbix/{data,conf,ssl,snmptraps}
cd /opt/zabbix
Create docker-compose.yml:
services:
postgres:
image: postgres:16-alpine
container_name: zabbix-postgres
environment:
- POSTGRES_USER=zabbix
- POSTGRES_PASSWORD=zabbix_password
- POSTGRES_DB=zabbix
volumes:
- ./data/postgres:/var/lib/postgresql/data
restart: unless-stopped
networks:
- zabbix
healthcheck:
test: ["CMD-SHELL", "pg_isready -U zabbix"]
interval: 10s
timeout: 5s
retries: 5
zabbix-server:
image: zabbix/zabbix-server-pgsql:7.4.7
container_name: zabbix-server
environment:
- DB_SERVER_HOST=postgres
- POSTGRES_USER=zabbix
- POSTGRES_PASSWORD=zabbix_password
- POSTGRES_DB=zabbix
- ZBX_SERVER_NAME=Zabbix Server
- PHP_TZ=UTC
volumes:
- ./conf/zabbix_server.conf:/etc/zabbix/zabbix_server.conf:ro
- ./snmptraps:/var/lib/zabbix/snmptraps:rw
- ./data/zabbix:/var/lib/zabbix:rw
ports:
- "10051:10051"
depends_on:
postgres:
condition: service_healthy
restart: unless-stopped
networks:
- zabbix
zabbix-web:
image: zabbix/zabbix-web-apache-pgsql:7.4.7
container_name: zabbix-web
environment:
- DB_SERVER_HOST=postgres
- POSTGRES_USER=zabbix
- POSTGRES_PASSWORD=zabbix_password
- POSTGRES_DB=zabbix
- ZBX_SERVER_HOST=zabbix-server
- PHP_TZ=UTC
ports:
- "80:8080"
- "443:8443"
volumes:
- ./ssl:/etc/ssl/ssl:ro
- ./conf/php-zabbix.conf:/etc/zabbix/conf.d/zabbix.conf:ro
depends_on:
- zabbix-server
restart: unless-stopped
networks:
- zabbix
zabbix-agent2:
image: zabbix/zabbix-agent2:7.4.7
container_name: zabbix-agent2
environment:
- ZBX_HOSTNAME=Docker-Host
- ZBX_SERVER_HOST=zabbix-server
- ZBX_SERVER_PORT=10051
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./conf/zabbix_agentd.conf:/etc/zabbix/zabbix_agentd.conf:ro
ports:
- "10050:10050"
depends_on:
- zabbix-server
restart: unless-stopped
networks:
- zabbix
pid: host
networks:
zabbix:
driver: bridge
Create conf/zabbix_server.conf for server tuning:
### Option: StartPollers
StartPollers=50
### Option: CacheSize
CacheSize=128M
### Option: HistoryCacheSize
HistoryCacheSize=128M
### Option: ValueCacheSize
ValueCacheSize=256M
Create conf/zabbix_agentd.conf for agent configuration:
Server=127.0.0.1,zabbix-server
ServerActive=zabbix-server
Hostname=Docker-Host
docker compose up -d
Note: Initial database setup may take 5-10 minutes.
Check container status:
docker compose ps
View server logs:
docker compose logs -f zabbix-server
View web logs:
docker compose logs -f zabbix-web
Access web UI at http://SERVER_IP/zabbix with default credentials:
AdminzabbixChange the default password immediately!
docker compose exec zabbix-server zabbix_server -R config_cache_reload
docker compose restart
docker compose down
docker compose pull
docker compose up -d
docker compose exec postgres psql -U zabbix -d zabbix -c "SELECT pg_size_pretty(pg_database_size('zabbix'));"
To monitor external hosts, configure the agent on target machines:
/etc/zabbix/zabbix_agent2.conf:Server=YOUR_ZABBIX_SERVER_IP
ServerActive=YOUR_ZABBIX_SERVER_IP
Hostname=target-hostname
For a complete stack with email notifications, add SMTP configuration:
zabbix-web:
environment:
- SMTPServer=smtp.example.com
- SMTPPort=587
- SMTPUser=notifications@example.com
- SMTPPassword=smtp_password
- SMTPHelo=example.com
- SMTPFrom=notifications@example.com
Running containers in production? We help with:
Need help? office@linux-server-admin.com or Contact Us