Home > Operation and Maintenance > Docker > How to deploy Zabbix into Docker

How to deploy Zabbix into Docker

PHPz
Release: 2023-04-25 17:05:37
Original
2207 people have browsed it

Zabbix is ​​a widely used open source monitoring system that can monitor and alert servers, network devices, applications, etc. Docker is a popular container technology that can help us deploy and manage applications more conveniently. How to deploy Zabbix into Docker? This article will introduce the steps to deploy Zabbix using Docker.

  1. Installing Docker

First, we need to install Docker on the server. This step will not be introduced in detail, you can refer to Docker official documentation.

  1. Prepare the MySQL database

Zabbix needs to use the MySQL database to store monitoring data, so we need to prepare a MySQL database. You can use Docker to start a MySQL container. Here we use the following command:

docker run --name zabbix-db -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7
Copy after login

This command will start a MySQL 5.7 container and set a container name named zabbix-db. At the same time, we use environment variables to set the MySQL root password to 123456.

  1. Prepare Zabbix server

Next we need to prepare a Zabbix server container. We can use the Zabbix image officially provided by Docker to start a Zabbix container. Use the following command:

docker run --name zabbix-server -e DB_SERVER_HOST=[MySQL容器IP] -e MYSQL_ROOT_PASSWORD=123456 -p 80:80 -p 10051:10051 -d zabbix/zabbix-server-mysql:latest
Copy after login

This command will start a latest version of Zabbix server container and set a container name called zabbix-server. At the same time, we use two environment variables:

  • DB_SERVER_HOST: This variable is used to specify the IP address or host name of the MySQL database. Because we started a MySQL container in the second step, this can be specified using the IP address of the container.
  • MYSQL_ROOT_PASSWORD: This is the root password of the MySQL database and needs to be the same as the second step.
  • -p option: This option is used to map the container internal port to the host port. Here we map Zabbix Web port 80 and Zabbix server port 10051 to the host.
  1. Preparing Zabbix front-end

Finally we need to start a Zabbix front-end container. Similarly, we can use the Zabbix image officially provided by Docker to start a Zabbix front-end container. Use the following command:

docker run --name zabbix-web -e DB_SERVER_HOST=[MySQL容器IP] -e MYSQL_ROOT_PASSWORD=123456 -e ZBX_SERVER_HOST=[Zabbix服务器容器IP] -p 8080:80 -d zabbix/zabbix-web-nginx-mysql:latest
Copy after login

This command will start a latest version of Zabbix front-end container and set a container name called zabbix-web. At the same time, we used three environment variables:

  • DB_SERVER_HOST: Same as step three.
  • MYSQL_ROOT_PASSWORD: Same as the third step.
  • ZBX_SERVER_HOST: This variable is used to specify the IP address or host name of the Zabbix server container.
  • -p option: Same as step 3.
  1. Connecting to Zabbix Web Interface

You can now connect to Zabbix Web Interface by visiting http://localhost:8080/zabbix (assuming Your host IP address is localhost). Just log in using the default username Admin and password zabbix.

Summary

In this article, we introduced how to use Docker to deploy the Zabbix monitoring system. We use Docker to start MySQL, Zabbix server and Zabbix front-end containers and connect them through environment variables and port mapping. Using Docker to deploy Zabbix allows us to manage and deploy the Zabbix system more conveniently, while also improving its flexibility and scalability.

The above is the detailed content of How to deploy Zabbix into Docker. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template