Since a few weeks I started using Docker and building containers and this is really fun to do. So one of my first public docker containers had to be something with Zabbix. 🙂
So I have created 2 docker containers;
- zabbix-server
- zabbix-web
So, here follows an description about the 2 containers.
Zabbix-Server
This container will run an zabbix-server. Jeah!
Its an Debian based container (As Debian is one of the smaller ones) and will only run the Zabbix Server. No database is running in this container, it is configured to use an MySQL database as backend. Before you can make use of this container, you’ll have to have an MySQL Server running somewhere in your environment. It will install Zabbix 3.0.1
How do we use this container? First we have to download it:
docker pull wdijkerman/zabbix-server
And this is how we start it:
docker run -p 10051:10051 --name zabbix-server \ -v /data/zabbix:/zabbix \ -e ROOTPASSWORD=secretpassword \ -e DBHOST=192.168.1.153 -e DBUSER=zabbix \ -e DBPASSWORD="zabbix-pass" \ -e DBPORT=3306 -e DBNAME=zabbix wdijkerman/zabbix-server
This docker container make use of an volume, mentioned with the -v parameter. This will mount the ‘/data/zabbix’ directory in the docker container as ‘/zabbix’. This directory contains the directories which are used for storing SSL (configuration) files, modules and scripts. With the -p option, we open the port on the host (10051) and forward it to the port to the docker container (10051).
The -e values which you see are environment settings that are passed into the docker container. These environment settings are the actual Zabbix Server configuration options but in uppercase. As you might see, the settings in the example are used for connecting to the database ‘zabbix’ on host ‘192.168.1.153’ with username ‘zabbix’ and password ‘zabbix-pass’. I also specified the ‘ROOTPASSWORD’ setting, this is the password for the MySQL root user. When this is supplied, it will create the database (DBNAME) and create the user (DBUSER). If you don’t specify it (Which can of course) an database and user should already be created.
With this in mind, if we want to set the StartPollers parameter to 10, we have to update the run command by adding the following:
-e STARTPOLLERS=10
Now you can configure the Zabbix Server exactly like you want, just by adding some environment parameters in the command line before starting it.
But this is only the Zabbix Server, not the frontend.
Zabbix Web
This container contains only the Zabbix Web part, or the ‘frontend’. (docker hub)
Like the Zabbix Server, this is also an Debian based docker container and will only work with MySQL as database. It is running Apache 2.4.
How do we use this container? First we have to download it:
docker pull wdijkerman/zabbix-web
And this is how we start it:
docker run -p 80:80 --name zabbix-web \ -e ZABBIXURL=zabbix.example.com \ -e ZBXSERVERNAME=vserver-151 \ -e ZBXSERVER=192.168.1.151 \ -e DBHOST=192.168.1.153 -e DBUSER=zabbix \ -e DBPASSWORD="zabbix-pass" \ -e DBPORT=3306 -e DBNAME=zabbix wdijkerman/zabbix-web
The DB* settings are the same as for the Zabbix Server container, so I won’t describe them again. With the Zabbix Web container we open port 80 on the host and forward it to port 80 on the docker container.
With the ZABBIXURL setting, we specify the url on which the web interface is available. In this case, when we open ‘zabbix.example.com’ we get the login page of Zabbix. (Well, if you have access to the zabbix.example.com domain 😉 ) With the ZBXSERVERNAME setting we specify the name of the Zabbix Server and with ZBXSERVER we let the Zabbix Web know where it can find the Zabbix Server.
Please let me know if you find any issues with configuring it or encounter an bug. Also if you have improvements, please create an PR on github! 🙂
Links:
- Zabbix Server: Github, Docker hub
- Zabbix Web: Github, Docker hub