Zabbixは各ZabbixコンポーネントのDockerイメージをポータブルな自給自足のコンテナとして提供し、
デプロイとアップデート手順の迅速化を図っています。
Zabbixコンポーネントには、MySQL、PostgreSQLデータベースサポート、Apache2、Nginx Webサーバサポートが付属しています。
これらのイメージはそれぞれ別のイメージに分かれています。
ZabbixコンポーネントはUbuntu、Alpine Linux、CentOSのベースイメージで提供されます。
ベースイメージが更新された場合、すべてのイメージが最新のイメージにリビルドされるように設定されています。
github.com の Zabbix official repositoryを利用すれば、誰でもDockerファイルの変更を追うことができます。
プロジェクトをフォークしたり、公式 Docker ファイルをベースに独自のイメージを作成することができます。
全てのZabbixコンポーネントは以下のDockerリポジトリから入手可能です:
さらに、SNMP Trap もサポートされています。Ubuntu Trustyのみをベースにした追加リポジトリ(zabbix/zabbix-snmptrapsとして提供されています。
Zabbix server やZabbix proxy と連携することが可能です。
Zabbixコンポーネントの各リポジトリには、以下のタグが含まれています:
latest
- latest stable version of a Zabbix component based on Alpine Linux imagealpine-latest
- latest stable version of a Zabbix component based on Alpine Linux imageubuntu-latest
- latest stable version of a Zabbix component based on Ubuntu imagealpine-5.4-latest
- latest minor version of a Zabbix 5.4 component based on Alpine Linux imageubuntu-5.4-latest
- latest minor version of a Zabbix 5.4 component based on Ubuntu imagealpine-5.4.*
- different minor versions of a Zabbix 5.4 component based on Alpine Linux image, where *
is the minor version of Zabbix componentubuntu-5.4.*
- different minor versions of a Zabbix 5.4 component based on Ubuntu image, where *
is the minor version of Zabbix componentすべてのZabbixコンポーネントイメージは、設定を制御するための環境変数を提供しています。これらの環境変数は
各コンポーネントリポジトリにリストアップされています。これらの環境変数は、Zabbix の設定ファイルのオプションですが、
命名方法が異なります。例えば、ZBX_LOGSLOWQUERIES
は Zabbix server と Zabbix proxy 設定ファイルの
LogSlowQueries
と 同じ意味です。
設定オプションの中には、変更が許されないものがあります。例えば、PIDFile
や LogType
などです。
一部のコンポーネントには、公式のZabbix設定ファイルには存在しない特定の環境変数があります:
変数 | コンポーネント | 説明 |
DB_SERVER_HOST |
Server Proxy Web interface |
This variable is IP or DNS name of MySQL or PostgreSQL server. By default, value is mysql-server or postgres-server for MySQL or PostgreSQL respectively |
DB_SERVER_PORT |
Server Proxy Web interface |
This variable is port of MySQL or PostgreSQL server. By default, value is '3306' or '5432' respectively. |
MYSQL_USER |
Server Proxy Web-interface |
MySQL database user. By default, value is 'zabbix'. |
MYSQL_PASSWORD |
Server Proxy Web interface |
MySQL database password. By default, value is 'zabbix'. |
MYSQL_DATABASE |
Server Proxy Web interface |
Zabbix database name. By default, value is 'zabbix' for Zabbix server and 'zabbix_proxy' for Zabbix proxy. |
POSTGRES_USER |
Server Web interface |
PostgreSQL database user. By default, value is 'zabbix'. |
POSTGRES_PASSWORD |
Server Web interface |
PostgreSQL database password. By default, value is 'zabbix'. |
POSTGRES_DB |
Server Web interface |
Zabbix database name. By default, value is 'zabbix' for Zabbix server and 'zabbix_proxy' for Zabbix proxy. |
PHP_TZ |
Web-interface | Timezone in PHP format. Full list of supported timezones are available on php.net. By default, value is 'Europe/Riga'. |
ZBX_SERVER_NAME |
Web interface | Visible Zabbix installation name in right top corner of the web interface. By default, value is 'Zabbix Docker' |
ZBX_JAVAGATEWAY_ENABLE |
Server Proxy |
Enables communication with Zabbix Java gateway to collect Java related checks. By default, value is "false" |
ZBX_ENABLE_SNMP_TRAPS |
Server Proxy |
Enables SNMP trap feature. It requires zabbix-snmptraps instance and shared volume /var/lib/zabbix/snmptraps to Zabbix server or Zabbix proxy. |
イメージでは、いくつかのマウントポイントを使用することができます。
これらのマウントポイントは、Zabbixコンポーネントの種類によって異なります:
ボリューム | 説明 |
Zabbix agent | |
/etc/zabbix/zabbix_agentd.d | The volume allows to include *.conf files and extend Zabbix agent using the UserParameter feature |
/var/lib/zabbix/modules | The volume allows to load additional modules and extend Zabbix agent using the LoadModule feature |
/var/lib/zabbix/enc | The volume is used to store TLS-related files. These file names are specified using ZBX_TLSCAFILE , ZBX_TLSCRLFILE , ZBX_TLSKEY_FILE and ZBX_TLSPSKFILE environment variables |
Zabbix server | |
/usr/lib/zabbix/alertscripts | The volume is used for custom alert scripts. It is the AlertScriptsPath parameter in zabbix_server.conf |
/usr/lib/zabbix/externalscripts | The volume is used by external checks. It is the ExternalScripts parameter in zabbix_server.conf |
/var/lib/zabbix/modules | The volume allows to load additional modules and extend Zabbix server using the LoadModule feature |
/var/lib/zabbix/enc | The volume is used to store TLS related files. These file names are specified using ZBX_TLSCAFILE , ZBX_TLSCRLFILE , ZBX_TLSKEY_FILE and ZBX_TLSPSKFILE environment variables |
/var/lib/zabbix/ssl/certs | The volume is used as location of SSL client certificate files for client authentication. It is the SSLCertLocation parameter in zabbix_server.conf |
/var/lib/zabbix/ssl/keys | The volume is used as location of SSL private key files for client authentication. It is the SSLKeyLocation parameter in zabbix_server.conf |
/var/lib/zabbix/ssl/ssl_ca | The volume is used as location of certificate authority (CA) files for SSL server certificate verification. It is the SSLCALocation parameter in zabbix_server.conf |
/var/lib/zabbix/snmptraps | The volume is used as location of snmptraps.log file. It could be shared by zabbix-snmptraps container and inherited using the volumes_from Docker option while creating a new instance of Zabbix server. SNMP trap processing feature could be enabled by using shared volume and switching the ZBX_ENABLE_SNMP_TRAPS environment variable to 'true' |
/var/lib/zabbix/mibs | The volume allows to add new MIB files. It does not support subdirectories, all MIBs must be placed in /var/lib/zabbix/mibs |
Zabbix proxy | |
/usr/lib/zabbix/externalscripts | The volume is used by external checks. It is the ExternalScripts parameter in zabbix_proxy.conf |
/var/lib/zabbix/modules | The volume allows to load additional modules and extend Zabbix server using the LoadModule feature |
/var/lib/zabbix/enc | The volume is used to store TLS related files. These file names are specified using ZBX_TLSCAFILE , ZBX_TLSCRLFILE , ZBX_TLSKEY_FILE and ZBX_TLSPSKFILE environment variables |
/var/lib/zabbix/ssl/certs | The volume is used as location of SSL client certificate files for client authentication. It is the SSLCertLocation parameter in zabbix_proxy.conf |
/var/lib/zabbix/ssl/keys | The volume is used as location of SSL private key files for client authentication. It is the SSLKeyLocation parameter in zabbix_proxy.conf |
/var/lib/zabbix/ssl/ssl_ca | The volume is used as location of certificate authority (CA) files for SSL server certificate verification. It is the SSLCALocation parameter in zabbix_proxy.conf |
/var/lib/zabbix/snmptraps | The volume is used as location of snmptraps.log file. It could be shared by the zabbix-snmptraps container and inherited using the volumes_from Docker option while creating a new instance of Zabbix server. SNMP trap processing feature could be enabled by using shared volume and switching the ZBX_ENABLE_SNMP_TRAPS environment variable to 'true' |
/var/lib/zabbix/mibs | The volume allows to add new MIB files. It does not support subdirectories, all MIBs must be placed in /var/lib/zabbix/mibs |
Zabbix web interface based on Apache2 web server | |
/etc/ssl/apache2 | The volume allows to enable HTTPS for Zabbix web interface. The volume must contain the two ssl.crt and ssl.key files prepared for Apache2 SSL connections |
Zabbix web interface based on Nginx web server | |
/etc/ssl/nginx | The volume allows to enable HTTPS for Zabbix web interface. The volume must contain the two ssl.crt , ssl.key files and dhparam.pem prepared for Nginx SSL connections |
Zabbix snmptraps | |
/var/lib/zabbix/snmptraps | The volume contains the snmptraps.log log file named with received SNMP traps |
/var/lib/zabbix/mibs | The volume allows to add new MIB files. It does not support subdirectories, all MIBs must be placed in /var/lib/zabbix/mibs |
詳細については、Docker Hub の Zabbix 公式リポジトリを参照してください。
** 例1 **
この例では、MySQLデータベースをサポートしたZabbix server 、Nginx WebサーバをベースにしたZabbix Webインタフェース、
Zabbix Java gateway の実行方法をデモンストレーションします
1. Zabbixコンポーネントコンテナ専用のネットワークの作成:
2. 空のMySQLサーバーインスタンスを起動
# docker run --name mysql-server -t \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix_pwd" \
-e MYSQL_ROOT_PASSWORD="root_pwd" \
--network=zabbix-net \
-d mysql:8.0 \
--restart unless-stopped \
--character-set-server=utf8 --collation-server=utf8_bin \
--default-authentication-plugin=mysql_native_password
3. Zabbix Java gateway インスタンスの起動
# docker run --name zabbix-java-gateway -t \
--network=zabbix-net \
--restart unless-stopped \
-d zabbix/zabbix-java-gateway:alpine-5.4-latest
4. Zabbix server インスタンスを起動し、作成したMySQLサーバインスタンスとリンク
# docker run --name zabbix-server-mysql -t \
-e DB_SERVER_HOST="mysql-server" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix_pwd" \
-e MYSQL_ROOT_PASSWORD="root_pwd" \
-e ZBX_JAVAGATEWAY="zabbix-java-gateway" \
--network=zabbix-net \
-p 10051:10051 \
--restart unless-stopped \
-d zabbix/zabbix-server-mysql:alpine-5.4-latest
Zabbix server インスタンスは10051/TCPポート(Zabbix trapper)をホストマシンに公開します。
5. Zabbix Web インタフェースを起動し、作成したMySQLサーバとZabbix server インスタンスを連携
# docker run --name zabbix-web-nginx-mysql -t \
-e ZBX_SERVER_HOST="zabbix-server-mysql" \
-e DB_SERVER_HOST="mysql-server" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix_pwd" \
-e MYSQL_ROOT_PASSWORD="root_pwd" \
--network=zabbix-net \
-p 80:8080 \
--restart unless-stopped \
-d zabbix/zabbix-web-nginx-mysql:alpine-5.4-latest
Zabbix Web インタフェースインスタンスはホストマシンに対して80/TCPポート(HTTP)を公開します。
** 例2 **
この例では、PostgreSQLデータベースをサポートしたZabbix server 、Nginx WebサーバをベースにしたZabbix Webインタフェース、 SNMP Trap 機能の実行方法を示しています。
1. Zabbixコンポーネントコンテナ専用のネットワークの作成:
2. 空のMySQLサーバーインスタンスを起動
# docker run --name postgres-server -t \
-e POSTGRES_USER="zabbix" \
-e POSTGRES_PASSWORD="zabbix_pwd" \
-e POSTGRES_DB="zabbix" \
--network=zabbix-net \
--restart unless-stopped \
-d postgres:latest
3. Zabbix snmptraps インスタンスの起動
# docker run --name zabbix-snmptraps -t \
-v /zbx_instance/snmptraps:/var/lib/zabbix/snmptraps:rw \
-v /var/lib/zabbix/mibs:/usr/share/snmp/mibs:ro \
--network=zabbix-net \
-p 162:1162/udp \
--restart unless-stopped \
-d zabbix/zabbix-snmptraps:alpine-5.4-latest
Zabbix snmptrapインスタンスはホストマシンに162/UDPポート(SNMP trap)を公開します。
4. Zabbix server インスタンスを起動し、作成したPostgreSQLサーバインスタンスとリンク
# docker run --name zabbix-server-pgsql -t \
-e DB_SERVER_HOST="postgres-server" \
-e POSTGRES_USER="zabbix" \
-e POSTGRES_PASSWORD="zabbix_pwd" \
-e POSTGRES_DB="zabbix" \
-e ZBX_ENABLE_SNMP_TRAPS="true" \
--network=zabbix-net \
-p 10051:10051 \
--volumes-from zabbix-snmptraps \
--restart unless-stopped \
-d zabbix/zabbix-server-pgsql:alpine-5.4-latest
Zabbixサーバインスタンスはホストマシンに10051/TCPポート(Zabbix trapper)を公開します。
5. Zabbix Web インタフェースを起動し、作成したPostgreSQLサーバとZabbix server インスタンスを連携
# docker run --name zabbix-web-nginx-pgsql -t \
-e ZBX_SERVER_HOST="zabbix-server-pgsql" \
-e DB_SERVER_HOST="postgres-server" \
-e POSTGRES_USER="zabbix" \
-e POSTGRES_PASSWORD="zabbix_pwd" \
-e POSTGRES_DB="zabbix" \
--network=zabbix-net \
-p 443:8443 \
-p 80:8080 \
-v /etc/ssl/nginx:/etc/ssl/nginx:ro \
--restart unless-stopped \
-d zabbix/zabbix-web-nginx-pgsql:alpine-5.4-latest
Zabbixウェブインタフェースインスタンスはホストマシンに対して443/TCPポート(HTTPS)を公開します。
ディレクトリ /etc/ssl/nginx に必要な名前の証明書が含まれている必要があります。
** 例3 **
この例では、MySQLデータベースをサポートしたZabbix server、Nginx WebサーバをベースにしたZabbix Webインタフェース、
Zabbix Java gateway をRed Hat 8上でpodman
を使用して実行する方法を説明します。
1. zabbix
という名前と公開ポート(Webインターフェース、Zabbix server trapper)を持つ新しいPodを作成:
2. (オプション) zabbix
pod の場所にある Zabbix agent コンテナを起動:
podman run --name zabbix-agent \
-eZBX_SERVER_HOST="127.0.0.1,localhost" \
--restart=always \
--pod=zabbix \
-d registry.connect.redhat.com/zabbix/zabbix-agent-50:latest
3. ホストに ./mysql/
ディレクトリを作成し、Oracle MySQL server 8.0 を起動:
podman run --name mysql-server -t \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix_pwd" \
-e MYSQL_ROOT_PASSWORD="root_pwd" \
-v ./mysql/:/var/lib/mysql/:Z \
--restart=always \
--pod=zabbix \
-d mysql:8.0 \
--character-set-server=utf8 --collation-server=utf8_bin \
--default-authentication-plugin=mysql_native_password
4. Zabbix server コンテナの起動:
podman run --name zabbix-server-mysql -t \
-e DB_SERVER_HOST="127.0.0.1" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix_pwd" \
-e MYSQL_ROOT_PASSWORD="root_pwd" \
-e ZBX_JAVAGATEWAY="127.0.0.1" \
--restart=always \
--pod=zabbix \
-d registry.connect.redhat.com/zabbix/zabbix-server-mysql-50
5. Zabbix Java gatewayコンテナの起動:
podman run --name zabbix-java-gateway -t \
--restart=always \
--pod=zabbix \
-d registry.connect.redhat.com/zabbix/zabbix-java-gateway-50
6. Zabbix Webインタフェースコンテナの起動:
podman run --name zabbix-web-mysql -t \
-e ZBX_SERVER_HOST="127.0.0.1" \
-e DB_SERVER_HOST="127.0.0.1" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix_pwd" \
-e MYSQL_ROOT_PASSWORD="root_pwd" \
--restart=always \
--pod=zabbix \
-d registry.connect.redhat.com/zabbix/zabbix-web-mysql-50
ポッド zabbix
は、zabbix-web-mysql
コンテナの 8080/TCP ポートからホストマシンに 80/TCP ポート(HTTP)を公開します。
ZabbixはDocker上でマルチコンテナZabbixコンポーネントを定義し、実行するための Compose ファイルも提供しています。
これらの Compose ファイルはgithub.com:https://github.com/zabbix/zabbix-dockerのZabbix docker公式リポジトリで入手可能です。
これらの Compose ファイルはサンプルとして追加されており、オーバーロードされています。例えば、MySQLとSQLite3をサポートした
プロキシが含まれています。
Compose ファイルにはいくつかのバージョンがあります:
ファイル名 | 説明 |
docker-compose_v3_alpine_mysql_latest.yaml |
The compose file runs the latest version of Zabbix 5.4 components on Alpine Linux with MySQL database support. |
docker-compose_v3_alpine_mysql_local.yaml |
The compose file locally builds the latest version of Zabbix 5.4 and runs Zabbix components on Alpine Linux with MySQL database support. |
docker-compose_v3_alpine_pgsql_latest.yaml |
The compose file runs the latest version of Zabbix 5.4 components on Alpine Linux with PostgreSQL database support. |
docker-compose_v3_alpine_pgsql_local.yaml |
The compose file locally builds the latest version of Zabbix 5.4 and runs Zabbix components on Alpine Linux with PostgreSQL database support. |
docker-compose_v3_centos_mysql_latest.yaml |
The compose file runs the latest version of Zabbix 5.4 components on CentOS 8 with MySQL database support. |
docker-compose_v3_centos_mysql_local.yaml |
The compose file locally builds the latest version of Zabbix 5.4 and runs Zabbix components on CentOS 8 with MySQL database support. |
docker-compose_v3_centos_pgsql_latest.yaml |
The compose file runs the latest version of Zabbix 5.4 components on CentOS 8 with PostgreSQL database support. |
docker-compose_v3_centos_pgsql_local.yaml |
The compose file locally builds the latest version of Zabbix 5.4 and runs Zabbix components on CentOS 8 with PostgreSQL database support. |
docker-compose_v3_ubuntu_mysql_latest.yaml |
The compose file runs the latest version of Zabbix 5.4 components on Ubuntu 20.04 with MySQL database support. |
docker-compose_v3_ubuntu_mysql_local.yaml |
The compose file locally builds the latest version of Zabbix 5.4 and runs Zabbix components on Ubuntu 20.04 with MySQL database support. |
docker-compose_v3_ubuntu_pgsql_latest.yaml |
The compose file runs the latest version of Zabbix 5.4 components on Ubuntu 20.04 with PostgreSQL database support. |
docker-compose_v3_ubuntu_pgsql_local.yaml |
The compose file locally builds the latest version of Zabbix 5.4 and runs Zabbix components on Ubuntu 20.04 with PostgreSQL database support. |
利用可能なDocker Composeファイルは、Docker Composeのバージョン3に対応しています。
Docker Composeは、composeファイルを使ってZabbixコンポーネントを実行すると、composeファイルのあるフォルダに
zbx_env
ディレクトリが作成されます。このディレクトリには、上記のVolumesセクションで説明したものと同じ構造の
データベースを格納するためのディレクトリが作成されます。
また、/etc/localtime
と /etc/timezone
ファイル用の読み込み専用ボリュームも用意されます。
github.comのcomposeファイルと同じディレクトリに、composeファイル内の各コンポーネントのデフォルトの環境変数が書かれた
ファイルがあります。これらの環境ファイルは、.env_<コンポーネントの種類>
のような名前になっています。
** Example 1 **
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 **
The command will download base image Ubuntu 20.04 (focal), then build Zabbix 5.4 components locally and run them in detach mode.