Installing Zabbix from docker containers

 I needed to refresh my aged Zabbix installation and I wanted to use a docker based solution, to keep it isolated from other components in the network. There are some caveats that need some time to resolve.

So I selected version 5.0 LTS, in the hope, that after setting it up, I do not need to replace it quickly. After reading the documentation and trying to understand it, I decided to use my already existing sql server, which resides at sql.mydomain.com. Quickly copied the docker run command into a batch file and launched it:

docker run --name zabbix-server -t \
      -e DB_SERVER_HOST="sql.mydomain.com" \
      -e MYSQL_DATABASE="zabbix" \
      -e MYSQL_USER="zabbix" \
      -e MYSQL_PASSWORD="verysecret" \
      --network=home \
      --ip 192.168.11.183 \
      --restart unless-stopped \
      -d zabbix/zabbix-server-mysql:alpine-5.0-latest 

As this is a small installation I did not created a separate network for docker, but simply put it on the existing network.

I started the script and watched the log:

docker logs zabbix-server

After a while it said, that it can not run, because the user database is empty :-(

So I decided to start over with the database population, added one line to the end of the docker run command:

      -d zabbix/zabbix-server-mysql:alpine-5.0-latest \
      bash

After stopping and deleting the previous container, I started the new one, and this caused, that the init scripts were not run, but the container remained up and running. First I have deleted all tables from the zabbix database, then logged in to the container and recreated the database:

docker exec -ti zabbix-server bash
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p -h sql.mysomain.com zabbix

After this I have stopped and deleted this container, removed the bash command from the end of the docker run file and restarted the container. Now fortunately all logs were ok, and the server started to run.

Next I have set up the web interface:

docker run --name zabbix-web -t \
      -e ZBX_SERVER_HOST="192.168.11.183" \
      -e DB_SERVER_HOST="sql.mydomain.com" \
      -e MYSQL_DATABASE="zabbix" \
      -e MYSQL_USER="zabbix" \
      -e MYSQL_PASSWORD="verysecret" \
      --network=home \
          --ip 192.168.11.184 \
      --restart unless-stopped \
      -d zabbix/zabbix-web-nginx-mysql:alpine-5.0-latest 


This started without problems, but when I logged in to http://192.168.11.184:8080, I just got a message the the database authentication failed :-) 

Fortunately found this post and I knew that the problem is the mysql authentication method. Somehow I could not enter the SQL command to change it from phpMyAdmin, so I had to log in to the sql server as root and issue: 

ALTER USER 'zabbix'@'localhost' IDENTIFIED WITH mysql_native_password BY 'verysecret';

After that the we interface started to work, and I could log in with Admin:zabbix.

Comments

Popular posts from this blog

Setting ethernet interface speed in /etc/network/interfaces