Zabbix provides Docker images for each Zabbix component as portable and self-sufficient containers to speed up deployment and update procedure.

Zabbix 组件支持 MySQL 和 PostgreSQL 数据库、Apache2 和 Nginx Web 服务器。这些镜像被分成多个不同的镜像。

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

Docker 的基础镜像

Zabbix 组件提供了 Ubuntu、Alpine Linux 和 CentOS 的基础镜像:

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.

Zabbix agent、Zabbix proxy、Zabbix server 和 Zabbix 应用镜像均基于 Alpine Linux 3.4 版,所有其他映像均基于 Alpine Linux 3.7。

Zabbix agent, Zabbix proxy, Zabbix server and Zabbix appliance images are based on Alpine Linux version 3.4, all other images are based on Alpine Linux 3.7.

Docker 源文件

每个人都可以在 上使用 Zabbix 官方镜像仓库,并关注其 Docker 文件变更情况。您可以根据官方 Docker 文件复制此项目或制作自己的镜像。

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

组件

所有 Zabbix 组件都可在以下 Docker 镜像仓库中使用:

All Zabbix components are available in the following Docker repositories:

  • MySQL 数据库和 Nginx Web 服务器支持的 Zabbix 应用 - zabbix/zabbix-appliance

  • Zabbix appliance with MySQL database support and Nginx web-server -

  • Zabbix agent - zabbix/zabbix-agent

  • Zabbix server

  • Zabbix server

  • Zabbix web-interface

    • 基于 Apache2 Web 服务器以及支持 MySQL 数据库的 Zabbix web 接口 -

    • 基于 Apache2 Web 服务器以及支持 PostgreSQL 数据库的 Zabbix web 接口 - zabbix/zabbix-web-apache-pgsql

    • 基于 Nginx Web 服务器以及支持 MySQL 数据库的 Zabbix web 接口 -

    • 基于 Nginx Web 服务器以及支持 PostgreSQL 数据库的 Zabbix web 接口 - - zabbix/zabbix-web-nginx-pgsql

  • Zabbix web-interface

    • Zabbix web-interface based on Apache2 web server with MySQL database support -

    • Zabbix web-interface based on Apache2 web server with PostgreSQL database support - zabbix/zabbix-web-apache-pgsql

    • Zabbix web-interface based on Nginx web server with MySQL database support -

    • Zabbix web-interface based on Nginx web server with PostgreSQL database support - zabbix/zabbix-web-nginx-pgsql

  • Zabbix proxy

  • Zabbix Java Gateway -

此外,对于 SNMP trap 的支持,它仅作为基于 Ubuntu Trusty 的额外镜像仓库 (zabbix/zabbix-snmptraps) 提供。它可以与 Zabbix server 和 Zabbix proxy 关联。

版本

Zabbix 组件的每个镜像仓库都包含了下列标签:

  • - 基于 Alpine Linux 镜像的最新稳定版的 Zabbix 组件;

  • alpine-latest - 基于 Alpine Linux 镜像的最新稳定版的 Zabbix 组件;latest stable version of a Zabbix component based on Alpine Linux image

  • ubuntu-latest - 基于 Ubuntu 镜像的最新稳定版的 Zabbix 组件;latest stable version of a Zabbix component based on Ubuntu image

  • alpine-4.0-latest - 基于 Alpine Linux 镜像的最新次要版本的 Zabbix 4.0 组件;latest minor version of a Zabbix 4.0 component based on Alpine Linux image

  • ubuntu-4.0-latest - 基于 Unbuntu 镜像的最新次要版本的 Zabbix 4.0 组件;latest minor version of a Zabbix 4.0 component based on Ubuntu image

  • alpine-4.0.* - 基于 Alpine Linux 镜像的不同次要版本的 Zabbix 4.0 组件,其中 * 代表 Zabbix 组件的次要版本;

  • ubuntu-4.0.* - 基于 Ubuntu 镜像的不同次要版本的 Zabbix 4.0 组件,其中 * 代表 Zabbix 组件的次要版本。

Each repository of Zabbix components contains the following tags:

  • latest - 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-4.0-latest - latest minor version of a Zabbix 4.0 component based on Alpine Linux image

  • ubuntu-4.0-latest - latest minor version of a Zabbix 4.0 component based on Ubuntu image

  • alpine-4.0.* - different minor versions of a Zabbix 4.0 component based on Alpine Linux image, where * is the minor version of Zabbix component

  • ubuntu-4.0.* - different minor versions of a Zabbix 4.0 component based on Ubuntu image, where * is the minor version of Zabbix component

使用方法

环境变量

所有 Zabbix 组件镜像都提供环境变量来控制配置。 这些环境变量在每个组件镜像仓库中列出。这些环境变量是 Zabbix 配置文件中的选项,但具有不同的命名方法。 例如,ZBX_LOGSLOWQUERIES 等于来自 Zabbix server 和 Zabbix proxy 配置文件的 LogSlowQueries

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.

一些配置选项是不允许更改的。例如,PIDFileLogType

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

其中,一些组件有特定的环境变量,而这些环境变量在官方 Zabbix 配置文件并不存在:

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

镜像中允许使用一些挂载点。根据 Zabbix 组件类型,这些挂载点各不相同:

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

关于更多的信息请在 Docker Hub 的 Zabbix 官方镜像仓库查看。

For additional information use Zabbix official repositories in Docker Hub.

使用方法实例

示例 1

该示例示范了如何使用内置 MySQL 数据库、Zabbix server、基于 Nginx Web 服务器的 Zabbix Web 界面和 Zabbix Java gateway 来运行 Zabbix 应用。

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

Zabbix 应用实例将 10051/TCP 端口(Zabbix trapper)和80/TCP 端口(HTTP)暴露给主机。

Zabbix appliance instance exposes 10051/TCP port (Zabbix trapper) and 80/TCP port (HTTP) to host machine.

示例 2

该示例示范了如何运行 MySQL 数据库支持、基于 Nginx Web 服务器的 Zabbix Web 界面和 Zabbix Java gateway。

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. 首先,启动空的 MySQL 服务器实例。

1. Start empty MySQL server instance

  1. # docker run --name mysql-server -t \
  2. -e MYSQL_DATABASE="zabbix" \
  3. -e MYSQL_USER="zabbix" \
  4. -e MYSQL_PASSWORD="zabbix_pwd" \
  5. -e MYSQL_ROOT_PASSWORD="root_pwd" \
  6. -d mysql:5.7 \
  7. --character-set-server=utf8 --collation-server=utf8_bin

2. 其次,启动 Zabbix Java gateway 实例

2. Start Zabbix Java gateway instance

  1. # docker run --name zabbix-java-gateway -t \
  2. -d zabbix/zabbix-java-gateway:latest

3. 然后,启动 Zabbix server 实例,并将其关联到已创建的 MySQL server 实例。

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

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

4. 最后,启动 Zabbix Web 界面,并将其关联到已创建的 MySQL server 和 Zabbix server 实例。

4. 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 DB_SERVER_HOST="mysql-server" \
  3. -e MYSQL_DATABASE="zabbix" \
  4. -e MYSQL_PASSWORD="zabbix_pwd" \
  5. -e MYSQL_ROOT_PASSWORD="root_pwd" \
  6. --link zabbix-server-mysql:zabbix-server \
  7. -p 80:80 \
  8. -d zabbix/zabbix-web-nginx-mysql:latest

Zabbix web 界面实例将 80/TCP 端口(HTTP)暴露给主机。

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

示例 3

该示例示范了如何运行 PostgreSQL 数据库支持的 Zabbix server、基于 Nginx Web 服务器的 Zabbix Web 界面和 SNMP trap功能。

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. 首先,启动空的 PostgreSQL server 实例。

1. Start empty PostgreSQL server instance

  1. # docker run --name postgres-server -t \
  2. -e POSTGRES_USER="zabbix" \
  3. -e POSTGRES_PASSWORD="zabbix" \
  4. -e POSTGRES_DB="zabbix_pwd" \
  5. -d postgres:latest

2. 其次,启动 Zabbix snmptraps 实例。

2. Start Zabbix snmptraps instance

Zabbix snmptrap 实例将 162/UDP 端口(SNMP traps)暴露给主机。

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

3.然后,启动 Zabbix server 实例,并将其关联到已创建的 PostgreSQL server 实例。

3. 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" \
  5. -e POSTGRES_DB="zabbix_pwd" \
  6. -e ZBX_ENABLE_SNMP_TRAPS="true" \
  7. --link postgres-server:postgres \
  8. -p 10051:10051 \
  9. --volumes-from zabbix-snmptraps \
  10. -d zabbix/zabbix-server-pgsql:latest

Zabbix server 实例将 10051/TCP 端口(Zabbix trapper)暴露给主机。

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

4.最后,启动 Zabbix Web 界面,并将其关联到已创建的 PostgreSQL server 和 Zabbix server 实例。

4. 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" \
  5. -e POSTGRES_DB="zabbix_pwd" \
  6. --link postgres-server:postgres \
  7. --link zabbix-server-pgsql:zabbix-server \
  8. -p 443:443 \
  9. -v /etc/ssl/nginx:/etc/ssl/nginx:ro \
  10. -d zabbix/zabbix-web-nginx-pgsql:latest

Zabbix web 界面实例将 443/TCP 端口(HTTPS)暴露给主机。
/etc/ssl/nginx 目录必须包含具有所需名称的证书。.

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

Zabbix 为 Docker 提供了定义和运行复杂 Zabbix 组件的 compose 文件。这些 compose 文件可以在 github.com: https://github.com/zabbix/zabbix-docker 上的 Zabbix docker 官方镜像仓库中找到。这些 compose 文件作为示例添加,并支持广泛。例如,Zabbix proxy 支持 MySQL和 SQLite3。

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: . These compose files are added as examples, they are overloaded. For example, they contain proxies with MySQL and SQLite3 support.

以下为几个不同版本的 compose 文件:

There are a few different versions of compose files:

Docker compose 文件支持 Docker Compose 2 版本和 Docker Compose 3版本。

Available Docker compose files support both versions 2 and 3 of Docker Compose.

存储

Compose 文件已经配置支持主机上的存储。当你使用 Compose 文件运行 Zabbix 组件时,Docker Compose 将在其所在文件夹中创建一个 zbx_env 目录,该目录将包含于 章节所述相同的结构,以用于数据库存储。

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.

此外,还有卷 /etc/localtime/etc/timezone 下的文件为只读模式。

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

环境变量文件

在 github.com 上与存放 compose 文件的同一目录中,您可以在 compose 文件中找到每个组件的默认环境变量文件,这些环境变量文件的命令与 .env_<type of component> 类似。

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>.

示例

示例 1

这个命令将会为每个 Zabbix 组件下载最新的 Zabbix 4.0 镜像,并以 detach 模式运行。

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

不要忘记从 github.com 的 Zabbix 官方镜像仓库下载 .env_<type of component> 文件和 compose 文件。

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

示例 2

  1. # docker-compose -f ./docker-compose_v3_ubuntu_mysql_local.yaml up -d

The command will download base image Ubuntu 14.04, then build Zabbix 4.0 components locally and run them in detach mode.