Zabbix is an open source network monitoring tool. It supports not only network devices, but also servers (Linux and windows), java application, virtual machine, and even cloud services!

In this tutorial, I’ll walk through how to install Zabbix with docker step by step. Zabbix actually provides a lot of ways to install it - images on all the major cloud platform and virtual machines! But docker is lightweight and it fits my use case as I’m not installing it on cloud this time. You can find the official zabbix-docker repository here.

We’ll spin up 4 containers this time, each for: MYSQL database, Zabbix server, Zabbix web interface(nginx), and Zabbix agent.

Install MYSQL database

At the time of writing the latest version is MYSQL 8.0.21, but using the ’latest’ tag will always give you the latest version.

docker run –name zabbix-mysql-database -e MYSQL_ROOT_PASSWORD=“super-strong-password” -d mysql:latest

See, it’s only 1 command, how convenient!

Install Zabbix Server

docker run –name zabbix-server –link zabbix-mysql-database -e ZBX_HOSTNAME=“zabbix-server” -e DB_SERVER_HOST=“zabbix-mysql-database” -e MYSQL_USER=“root” -e MYSQL_PASSWORD=“super-strong-password” -p 10051:10051 -d zabbix/zabbix-server-mysql:latest

The ‘–link’ argument allows this container to access the MYSQL container that was created. The ‘-e’ argument provides environment variables. These arguments can be found here. You may want to use a password stronger than super-strong-password. Here, we also expose port 10051, so that other services can access it, the port 10051 is for agents to actively check the server.

Install Zabbix web interface

docker run –name zabbix-nginx-web –link zabbix-server –link zabbix-mysql-database -e DB_SERVER_HOST=“zabbix-mysql-database” -e MYSQL_USER=“root” -e MYSQL_PASSWORD=“super-strong-password” -e ZBX_SERVER_HOST=“zabbix-server” -e PHP_TZ=“Europe/Zurich” -p 8080:8080 -d zabbix/zabbix-web-nginx-mysql:latest

This container is linked to the MYSQL database as well as Zabbix server. Now, you may want to change the PHP_TZ timezone.

At this point, you can already access the server at http://localhost:8080 or http://your-server-ip:8080. But you will probably see the error: The server requested authentication method unknown to the client. This is because the default authentication plugin for MYSQL 8 is auth_socket, but our web server is using password to authenticate. Now, if we change the plugin back to password the website should work just fine.

First, we need connect to the database:

docker run -it –link zabbix-mysql-database –rm mysql mysql -h zabbix-mysql-database -u root -p

The password is what you defined above.

Then, change the authentication back to password:

ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘super-strong-password’;

ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘super-strong-password’;

Now you should be able to login the website just fine! The default username and password is: Admin and zabbix.

Install Zabbix agent

docker run –name zabbix-agent –link zabbix-server –privileged -e ZBX_HOSTNAME=“zabbix-agent” -e ZBX_SERVER_PORT=10051 -e ZBX_SERVER_HOST=“zabbix-server” -p 10050:10050 -d zabbix/zabbix-agent:latest

Here we give the agent container privileged so that it can access the metrics of the host.

Now in order for the Zabbix server to identify the agent so that it becomes available, we need to find the IP of the agent container:

docker inspect zabbix-agent | grep IPAddress

Next, go to the website:

  1. Configuration > Hosts > zabbix-agent
  2. Change the Interface IP address to the address of zabbix-agent container

Now, the Zabbix server is up and running and ready to monitor for any devices you add to it!