Skip to content

Instantly share code, notes, and snippets.

@mattintosh4
Last active July 17, 2017 07:38
Show Gist options
  • Save mattintosh4/6c7b79b48c11eec3181fc252dd5afb5a to your computer and use it in GitHub Desktop.
Save mattintosh4/6c7b79b48c11eec3181fc252dd5afb5a to your computer and use it in GitHub Desktop.
CentOS 7 & Zabbix 3.0
FROM centos:centos7
MAINTAINER m-yoshida
## Initialization
RUN localedef -i ja_JP -f UTF-8 /usr/lib/locale/ja_JP.UTF-8 \
&& sed -i'' '/^mirrorlist/{s|^|#|};/^#baseurl/{s|^#||;s|mirror.centos.org|ftp.riken.jp/Linux|}' /etc/yum.repos.d/CentOS-Base.repo \
&& sed -i'' '/^enable/{s|1|0|}' /etc/yum/pluginconf.d/*.conf \
&& rpm --import http://ftp.riken.jp/Linux/centos/RPM-GPG-KEY-CentOS-7 \
&& yum clean all \
&& yum update -y
## Zabbix installation
RUN rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm \
&& yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-web-japanese mariadb-server zabbix-agent \
&& yumdownloader zabbix-server-mysql && rpm -ivh --replacepkgs zabbix-server-mysql-3.0.*.rpm && rm -f zabbix-server-mysql-3.0.*.rpm \
&& yum clean all \
&& sed -i'' '/php_value date.timezone/{s|# ||;s|Europe/Riga|Asia/Tokyo|;}' /etc/httpd/conf.d/zabbix.conf
## MySQL Settings
# Disable database password
RUN /usr/libexec/mariadb-prepare-db-dir \
&& /bin/sh -c "/usr/bin/mysqld_safe & sleep 5" \
&& echo "create database zabbix character set utf8 collate utf8_bin; grant all privileges on zabbix.* to zabbix@localhost;" | mysql -uroot \
&& zcat /usr/share/doc/zabbix-server-mysql-3.0.*/create.sql.gz | mysql -uzabbix zabbix
# Enable database password
#RUN /usr/libexec/mariadb-prepare-db-dir \
#RUN /bin/sh -c "/usr/bin/mysqld_safe & sleep 5" \
#&& echo "create database zabbix character set utf8 collate utf8_bin; grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';" | mysql -uroot \
#&& zcat /usr/share/doc/zabbix-server-mysql-3.0.*/create.sql.gz | mysql -uzabbix -pzabbix zabbix
#RUN echo "DBPassword=zabbix" >>/etc/zabbix/zabbix_server.conf
EXPOSE 80
EXPOSE 10050 10051
CMD /usr/sbin/zabbix_server \
&& /usr/sbin/zabbix_agentd \
&& /bin/sh -c '/usr/bin/mysqld_safe & sleep 1' \
&& /usr/sbin/httpd -DFOREGROUND
@mattintosh4
Copy link
Author

mattintosh4 commented Jul 15, 2017

git clone https://gist.github.com/6c7b79b48c11eec3181fc252dd5afb5a.git docker-test
cd docker-test
docker pull centos:centos7
docker build .
docker run -ti --name zabbix -p 80:80 -p 10051:10051 ${IMAGE_ID}

http://localhost/zabbix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment