5 Installation from containers

    Zabbix components come with MySQL and PostgreSQL database support, Apache2 and Nginx web server support. These images are separated into different images.

    Docker base images

    Zabbix components are provided on Ubuntu, Alpine Linux and CentOS base images:

    All images are configured to rebuild latest images if base images are updated.

    Docker file sources

    Everyone can follow Docker file changes using the Zabbix official repository on . You can fork the project or make your own images based on official Docker files.

    Structure

    All Zabbix components are available in the following Docker repositories:

    • Zabbix agent -
    • Zabbix server
    • Zabbix web-interface
      • Zabbix web-interface based on Apache2 web server with MySQL database support - zabbix/zabbix-web-apache-mysql
      • Zabbix web-interface based on Apache2 web server with PostgreSQL database support -
      • Zabbix web-interface based on Nginx web server with MySQL database support - zabbix/zabbix-web-nginx-mysql
      • Zabbix web-interface based on Nginx web server with PostgreSQL database support -
    • Zabbix proxy
    • Zabbix Java Gateway - zabbix/zabbix-java-gateway

    Additionally there is SNMP trap support. It is provided as additional repository () based on Ubuntu Trusty only. It could be linked with Zabbix server and Zabbix proxy.

    Versions

    Each repository of Zabbix components contains the following tags:

    • - latest stable version of a Zabbix component based on Alpine Linux image
    • alpine-latest - latest stable version of a Zabbix component based on Alpine Linux image
    • ubuntu-latest - latest stable version of a Zabbix component based on Ubuntu image
    • alpine-5.4-latest - latest minor version of a Zabbix 5.4 component based on Alpine Linux image
    • ubuntu-5.4-latest - latest minor version of a Zabbix 5.4 component based on Ubuntu image
    • alpine-5.4.* - different minor versions of a Zabbix 5.4 component based on Alpine Linux image, where * is the minor version of Zabbix component
    • ubuntu-5.4.* - different minor versions of a Zabbix 5.4 component based on Ubuntu image, where * is the minor version of Zabbix component

    Usage

    Environment variables

    All Zabbix component images provide environment variables to control configuration. These environment variables are listed in each component repository. These environment variables are options from Zabbix configuration files, but with different naming method. For example, ZBX_LOGSLOWQUERIES is equal to LogSlowQueries from Zabbix server and Zabbix proxy configuration files.

    Some of configuration options are not allowed to change. For example, PIDFile and LogType.

    Some of components have specific environment variables, which do not exist in official Zabbix configuration files:

    Volumes

    The images allow to use some mount points. These mount points are different and depend on Zabbix component type:

    For additional information use Zabbix official repositories in Docker Hub.

    Usage examples

    Example 1

    The example demonstrates how to run Zabbix server with MySQL database support, Zabbix web interface based on the Nginx web server and Zabbix Java gateway.

    1. Create network dedicated for Zabbix component containers:

    2. Start empty MySQL server instance

    1. # docker run --name mysql-server -t \
    2. -e MYSQL_USER="zabbix" \
    3. -e MYSQL_PASSWORD="zabbix_pwd" \
    4. -e MYSQL_ROOT_PASSWORD="root_pwd" \
    5. --network=zabbix-net \
    6. -d mysql:8.0 \
    7. --restart unless-stopped \
    8. --character-set-server=utf8 --collation-server=utf8_bin \
    9. --default-authentication-plugin=mysql_native_password
    1. # docker run --name zabbix-java-gateway -t \
    2. --restart unless-stopped \
    3. -d zabbix/zabbix-java-gateway:alpine-5.4-latest

    4. Start Zabbix server instance and link the instance with created MySQL server instance

    1. # docker run --name zabbix-server-mysql -t \
    2. -e DB_SERVER_HOST="mysql-server" \
    3. -e MYSQL_DATABASE="zabbix" \
    4. -e MYSQL_USER="zabbix" \
    5. -e MYSQL_PASSWORD="zabbix_pwd" \
    6. -e MYSQL_ROOT_PASSWORD="root_pwd" \
    7. -e ZBX_JAVAGATEWAY="zabbix-java-gateway" \
    8. --network=zabbix-net \
    9. -p 10051:10051 \
    10. --restart unless-stopped \
    11. -d zabbix/zabbix-server-mysql:alpine-5.4-latest

    Zabbix server instance exposes 10051/TCP port (Zabbix trapper) to host machine.

    5. Start Zabbix web interface and link the instance with created MySQL server and Zabbix server instances

    1. # docker run --name zabbix-web-nginx-mysql -t \
    2. -e ZBX_SERVER_HOST="zabbix-server-mysql" \
    3. -e DB_SERVER_HOST="mysql-server" \
    4. -e MYSQL_DATABASE="zabbix" \
    5. -e MYSQL_USER="zabbix" \
    6. -e MYSQL_PASSWORD="zabbix_pwd" \
    7. -e MYSQL_ROOT_PASSWORD="root_pwd" \
    8. --network=zabbix-net \
    9. -p 80:8080 \
    10. --restart unless-stopped \
    11. -d zabbix/zabbix-web-nginx-mysql:alpine-5.4-latest

    Zabbix web interface instance exposes 80/TCP port (HTTP) to host machine.

    Example 2

    The example demonstrates how to run Zabbix server with PostgreSQL database support, Zabbix web interface based on the Nginx web server and SNMP trap feature.

    1. Create network dedicated for Zabbix component containers:

    1. # docker network create --subnet 172.20.0.0/16 --ip-range 172.20.240.0/20 zabbix-net

    2. Start empty PostgreSQL server instance

    3. Start Zabbix snmptraps instance

    1. # docker run --name zabbix-snmptraps -t \
    2. -v /zbx_instance/snmptraps:/var/lib/zabbix/snmptraps:rw \
    3. -v /var/lib/zabbix/mibs:/usr/share/snmp/mibs:ro \
    4. --network=zabbix-net \
    5. -p 162:1162/udp \
    6. --restart unless-stopped \
    7. -d zabbix/zabbix-snmptraps:alpine-5.4-latest

    Zabbix snmptrap instance exposes the 162/UDP port (SNMP traps) to host machine.

    4. Start Zabbix server instance and link the instance with created PostgreSQL server instance

    1. # docker run --name zabbix-server-pgsql -t \
    2. -e DB_SERVER_HOST="postgres-server" \
    3. -e POSTGRES_USER="zabbix" \
    4. -e POSTGRES_PASSWORD="zabbix_pwd" \
    5. -e POSTGRES_DB="zabbix" \
    6. -e ZBX_ENABLE_SNMP_TRAPS="true" \
    7. --network=zabbix-net \
    8. -p 10051:10051 \
    9. --volumes-from zabbix-snmptraps \
    10. --restart unless-stopped \
    11. -d zabbix/zabbix-server-pgsql:alpine-5.4-latest

    Zabbix server instance exposes the 10051/TCP port (Zabbix trapper) to host machine.

    5. Start Zabbix web interface and link the instance with created PostgreSQL server and Zabbix server instances

    1. # docker run --name zabbix-web-nginx-pgsql -t \
    2. -e DB_SERVER_HOST="postgres-server" \
    3. -e POSTGRES_USER="zabbix" \
    4. -e POSTGRES_PASSWORD="zabbix_pwd" \
    5. -e POSTGRES_DB="zabbix" \
    6. --network=zabbix-net \
    7. -p 80:8080 \
    8. -v /etc/ssl/nginx:/etc/ssl/nginx:ro \
    9. --restart unless-stopped \
    10. -d zabbix/zabbix-web-nginx-pgsql:alpine-5.4-latest

    Zabbix web interface instance exposes the 443/TCP port (HTTPS) to host machine.
    Directory /etc/ssl/nginx must contain certificate with required name.

    Example 3

    The example demonstrates how to run Zabbix server with MySQL database support, Zabbix web interface based on the Nginx web server and Zabbix Java gateway using podman on Red Hat 8.

    1. podman pod create --name zabbix -p 80:8080 -p 10051:10051

    2. (optional) Start Zabbix agent container in zabbix pod location:

    1. podman run --name zabbix-agent \
    2. -eZBX_SERVER_HOST="127.0.0.1,localhost" \
    3. --restart=always \
    4. --pod=zabbix \
    5. -d registry.connect.redhat.com/zabbix/zabbix-agent-50:latest

    3. Create ./mysql/ directory on host and start Oracle MySQL server 8.0:

    3. Start Zabbix server container:

    1. podman run --name zabbix-server-mysql -t \
    2. -e DB_SERVER_HOST="127.0.0.1" \
    3. -e MYSQL_DATABASE="zabbix" \
    4. -e MYSQL_USER="zabbix" \
    5. -e MYSQL_PASSWORD="zabbix_pwd" \
    6. -e MYSQL_ROOT_PASSWORD="root_pwd" \
    7. -e ZBX_JAVAGATEWAY="127.0.0.1" \
    8. --restart=always \
    9. --pod=zabbix \
    10. -d registry.connect.redhat.com/zabbix/zabbix-server-mysql-50

    4. Start Zabbix Java Gateway container:

    1. podman run --name zabbix-java-gateway -t \
    2. --restart=always \
    3. --pod=zabbix \
    4. -d registry.connect.redhat.com/zabbix/zabbix-java-gateway-50

    5. Start Zabbix web-interface container:

    1. podman run --name zabbix-web-mysql -t \
    2. -e ZBX_SERVER_HOST="127.0.0.1" \
    3. -e DB_SERVER_HOST="127.0.0.1" \
    4. -e MYSQL_DATABASE="zabbix" \
    5. -e MYSQL_USER="zabbix" \
    6. -e MYSQL_PASSWORD="zabbix_pwd" \
    7. -e MYSQL_ROOT_PASSWORD="root_pwd" \
    8. --restart=always \
    9. --pod=zabbix \
    10. -d registry.connect.redhat.com/zabbix/zabbix-web-mysql-50

    Pod zabbix exposes 80/TCP port (HTTP) to host machine from 8080/TCP of zabbix-web-mysql container.

    Docker Compose

    Zabbix provides compose files also for defining and running multi-container Zabbix components in Docker. These compose files are available in Zabbix docker official repository on github.com: https://github.com/zabbix/zabbix-docker. These compose files are added as examples, they are overloaded. For example, they contain proxies with MySQL and SQLite3 support.

    There are a few different versions of compose files:

    Available Docker compose files support version 3 of Docker Compose.

    Storage

    Compose files are configured to support local storage on a host machine. Docker Compose will create a zbx_env directory in the folder with the compose file when you run Zabbix components using the compose file. The directory will contain the same structure as described above in the Volumes section and directory for database storage.

    There are also volumes in read-only mode for /etc/localtime and /etc/timezone files.

    Environment files

    In the same directory with compose files on github.com you can find files with default environment variables for each component in compose file. These environment files are named like .env_<type of component>.

    Examples

    Example 1

    1. # git checkout 5.4
    2. # docker-compose -f ./docker-compose_v3_alpine_mysql_latest.yaml up -d

    The command will download latest Zabbix 5.4 images for each Zabbix component and run them in detach mode.

    Do not forget to download .env_<type of component> files from github.com official Zabbix repository with compose files.

    Example 2

    1. # git checkout 5.4