1

I tried to install Zabbix-server-mysql on genuine centos image in docker container:

[root@desktop]# docker run --rm -ti centos:latest /bin/bash
[root@0e4f336ff674]# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
[root@0e4f336ff674]# rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
[root@0e4f336ff674]# yum install http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-server-mysql-3.2.3-1.el7.x86_64.rpm

This manual: https://www.zabbix.com/documentation/3.2/manual/installation/install_from_packages/server_installation_with_mysql requires a file "/usr/share/doc/zabbix-server-mysql-3.2.3/create.sql.gz" to be created during the installation due to its necessity to create zabbix DB on MySQL server. But this file appears missing:

[root@0e4f336ff674]# ls -ld /usr/share/doc/zabbix-server-mysql-3.2.3/create.sql.gz
ls: cannot access /usr/share/doc/zabbix-server-mysql-3.2.3/create.sql.gz: No such file or directory

The funny part is this file actually EXISTS in *.rpm file:

[root@0e4f336ff674]# rpm2cpio http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-server-mysql-3.2.3-1.el7.x86_64.rpm | cpio -t | grep create
./usr/share/doc/zabbix-server-mysql-3.2.3/create.sql.gz

Moreover, the package doesn't seem to have any pre- or post-install scripts that could delete the /usr/share/doc/zabbix-server-mysql-3.2.3/ directory:

[root@0e4f336ff674]# rpm -qp --scripts http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-server-mysql-3.2.3-1.el7.x86_64.rpm
preinstall scriptlet (using /bin/sh):
getent group zabbix > /dev/null || groupadd -r zabbix
getent passwd zabbix > /dev/null || \
    useradd -r -g zabbix -d /var/lib/zabbix -s /sbin/nologin \
    -c "Zabbix Monitoring System" zabbix
:
postinstall scriptlet (using /bin/sh):

if [ $1 -eq 1 ] ; then 
        # Initial installation 
        /usr/bin/systemctl preset zabbix-server.service >/dev/null 2>&1 || : 
fi 
/usr/sbin/update-alternatives --install /usr/sbin/zabbix_server \
    zabbix-server /usr/sbin/zabbix_server_mysql 10
:
<...>

So what could be the problem with it?

P.S.: I am aware of the exising official zabbix-on-docker images: github.com/zabbix/zabbix-docker

4 Answers 4

0

May be it blocks on "systemctl preset" because in a systemd-controlled operating system that one tries to talk to the systemd daemon to execute the command. However in a docker container there is no systemd daemon.

You could try to avoid that potential problem by using the https://github.com/gdraheim/docker-systemctl-replacement to execute the "systemctl preset".

1
  • I doubt that this is the problem since centos:latest has /usr/bin/systemctl already built in: [root@desktop]# docker run -ti --rm centos:latest /bin/bash [root@79cfd0768438 /]# ls -la /usr/bin/systemctl -rwxr-xr-x. 1 root root 645888 Mar 7 13:27 /usr/bin/systemctl Moreover, the %any_command% || : will always return TRUE because of || :, even if file doesn't exist: [root@79cfd0768438 /]# /NoSuchCommand || : bash: /NoSuchCommand: No such file or directory [root@79cfd0768438 /]# echo $? 0 Jun 30, 2018 at 9:10
0

According to https://github.com/tianon/docker-brew-ubuntu-core/issues/122, you should add this to the top of the Dockerfile:

# Do not exclude man pages & other documentation
RUN rm /etc/dpkg/dpkg.cfg.d/excludes
1
  • That’s very unlikely to help on a CentOS-based image. Feb 27, 2019 at 13:49
0

I couldn't figure out a way to get the create.sql.gz file to install while running inside a Docker CentOS 7 container (even though I can start it with systemd running properly), but I did the following workaround:

wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/4.2.6/zabbix-4.2.6.tar.gz/download
mv download download.tar.gz
tar -xzvf download.tar.gz
cd zabbix-4.2.6/database/mysql
mysql -uzabbix -p[password] zabbix < schema.sql
mysql -uzabbix -p[password] zabbix < images.sql
mysql -uzabbix -p[password] zabbix < data.sql

And then I could finish the frontend installation of Zabbix.

Annoying, but it worked and was the only way I could get this going without being able to source a create.sql.gz file from anywhere else.

0
0

The Yum configuration file /etc/yum.conf of the CentOS Docker image contains tsflags=nodocs which stops the documentation from installing.

The Zabbix create.sql.gz file is installed as part of the documentation and this is the reason why it's missing.

To install the create.sql.gz file either comment out the tsflags line in the /etc/yum.conf file or amend it removing no nodocs before installing Zabbix.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .