zabbix-dockerfile.sh
#1 mysql
mkdir /data/docker/mysql -p & cd /data/docker/mysql
#vim Dockerfile
FROM mysql:5.7
ENV LANG en_US.utf8
RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo Asia/Shanghai > /etc/timezone \
docker build -t debian-mysql5.7 .
docker run --hostname mysql --name debian-mysql-5.7 -t \
> -e MYSQL_USER="zabbix" \
> -e MYSQL_DATABASE="zabbix" \
> -e MYSQL_PASSWORD="passwd" \
> -e MYSQL_ROOT_PASSWORD="passwd" \
> -v /data/mysql:/var/lib/mysql:rw \
> -d debian-mysql5.7
#2 zabbix server
#cat Dockerfile
FROM zabbix/zabbix-server-mysql:latest
ENV LANG en_US.utf8
RUN apk add -U tzdata
RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo Asia/Shanghai > /etc/timezone \
docker build -t zabbix-server .
docker run --name zabbix-server -t \
> -p 10051:10051 \
> --hostname zabbix-server \
> -e DB_SERVER_HOST="debian-mysql-5.7" \
> -e MYSQL_DATABASE="zabbix" \
> -e MYSQL_USER="zabbix" \
> -e MYSQL_PASSWORD="passwd" \
> -e MYSQL_ROOT_PASSWORD="passwd" \
> -e ZBX_JAVAGATEWAY="zabbix-java-gateway" \
> --link debian-mysql-5.7:mysql \
> --link zabbix-java-gateway:zabbix-java-gateway \
> -d zabbix-server
#3 zabbix web
#cat Dockerfile
FROM zabbix/zabbix-web-nginx-mysql:latest
ENV LANG en_US.utf8
RUN apk add -U tzdata
RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo Asia/Shanghai > /etc/timezone \
docker build -t zabbix-web .
docker run --name zabbix-web -t \
> -p 80:80 \
> --hostname zabbix-web \
> -e PHP_TZ="Asia/Shanghai" \
> -e DB_SERVER_HOST="debian-mysql-5.7" \
> -e MYSQL_DATABASE="zabbix" \
> -e MYSQL_USER="zabbix" \
> -e MYSQL_PASSWORD="passwd" \
> -e MYSQL_ROOT_PASSWORD="passwd" \
> --link debian-mysql-5.7:mysql \
> --link zabbix-server:zabbix-server \
> -d zabbix-web
#安装 zabbix-agent
rpm -i https://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
yum -y install zabbix-agent
#配置文件
#[root@nginx ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=172.31.223.165 #容器IP
UnsafeUserParameters=1
Include=/etc/zabbix/zabbix_agentd.d/*.conf
#[root@nginx ~]# systemctl start zabbix-agent
Last updated