Reputation: 95
I am new in docker technology.
I want to install zabbix server using docker-compose.yml with only one container and connect it with host machine database(mysql) and also host machine apache2/nginx for zabbix frontend.
Is it possible? Please help.
Upvotes: 5
Views: 18810
Reputation: 3001
From the official Zabbix blog tutorial:
Clone the zabbix-docker repository:
git clone https://github.com/zabbix/zabbix-docker.git
cd zabbix-docker
Inside the zabbix-docker
directory:
agent docker-compose_v3_centos_mysql_latest.yaml docker-compose_v3_ol_pgsql_local.yaml kubernetes.yaml snmptraps
agent2 docker-compose_v3_centos_mysql_local.yaml docker-compose_v3_ubuntu_mysql_latest.yaml LICENSE web-apache-mysql
build.sh docker-compose_v3_centos_pgsql_latest.yaml docker-compose_v3_ubuntu_mysql_local.yaml proxy-mysql web-apache-pgsql
docker-compose_v3_alpine_mysql_latest.yaml docker-compose_v3_centos_pgsql_local.yaml docker-compose_v3_ubuntu_pgsql_latest.yaml proxy-sqlite3 web-nginx-mysql
docker-compose_v3_alpine_mysql_local.yaml docker-compose_v3_ol_mysql_latest.yaml docker-compose_v3_ubuntu_pgsql_local.yaml README.md web-nginx-pgsql
docker-compose_v3_alpine_pgsql_latest.yaml docker-compose_v3_ol_mysql_local.yaml generate-stackbrew-library.sh server-mysql web-service
docker-compose_v3_alpine_pgsql_local.yaml docker-compose_v3_ol_pgsql_latest.yaml java-gateway server-pgsql zabbix-appliance
Files ‘docker-compose-v2’ on the left are for an older Docker Compose version. Normally, if you have a fresh installation, you will not need them.
We will be using Docker Compose v3. What is the difference between those files with docker-compose-v3 in their name?
_alpine_
_centos_
_ubuntu_
_mysql_
_pgsql_
_latest.yaml
_local.yaml
Local means that we will be building an image locally from our local Docker files.
Latest means that we will be pulling it from the repository.
Checkout the version of Zabbix you want:
git checkout 5.0
Run one of the docker-compose
files 1:
docker-compose -f docker-compose_v3_alpine_mysql_latest.yaml up -d
1 Checkout the available ports, otherwise the services may fail to start.
Read their turorial for more information.
Upvotes: 7
Reputation: 815
That's the Docker Compose file I use. The difference here is that I use web frontend container instead of using host's Apache. On host Nginx I do proxy to the frontend.
I know using of the host network in containers isn't the best idea. But I had problems with backend and frontend connecting to my host's MySQL so this is a temporary workaround. Might be enough though for you.
Additionally I have following files in my compose directory:
.env_db_mysql - downloaded from https://github.com/zabbix/zabbix-docker
.env_srv - downloaded from https://github.com/zabbix/zabbix-docker
.env_web - downloaded from https://github.com/zabbix/zabbix-docker
.MYSQL_PASSWORD - contains a password to the DB
.MYSQL_USER - contains a user name to the DB
version: '3.5'
services:
zabbix-server:
image: zabbix/zabbix-server-mysql:alpine-5.2-latest
ports:
- "10051:10051"
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro
- ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro
- ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw
- ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro
- ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro
- ./zbx_env/var/lib/zabbix/ssh_keys:/var/lib/zabbix/ssh_keys:ro
- ./zbx_env/var/lib/zabbix/mibs:/var/lib/zabbix/mibs:ro
ulimits:
nproc: 65535
nofile:
soft: 20000
hard: 40000
env_file:
- .env_db_mysql
- .env_srv
secrets:
- MYSQL_USER
- MYSQL_PASSWORD
network_mode: "host"
stop_grace_period: 30s
sysctls:
- net.ipv4.ip_local_port_range=1024 65000
- net.ipv4.conf.all.accept_redirects=0
- net.ipv4.conf.all.secure_redirects=0
- net.ipv4.conf.all.send_redirects=0
labels:
com.zabbix.description: "Zabbix server with MySQL database support"
com.zabbix.company: "Zabbix LLC"
com.zabbix.component: "zabbix-server"
com.zabbix.dbtype: "mysql"
com.zabbix.os: "alpine"
zabbix-web-nginx-mysql:
image: zabbix/zabbix-web-nginx-mysql:alpine-5.2-latest
ports:
- "8081:8080"
- "8443:8443"
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- ./zbx_env/etc/ssl/nginx:/etc/ssl/nginx:ro
- ./zbx_env/usr/share/zabbix/modules/:/usr/share/zabbix/modules/:ro
env_file:
- .env_db_mysql
- .env_web
secrets:
- MYSQL_USER
- MYSQL_PASSWORD
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/"]
interval: 10s
timeout: 5s
retries: 3
start_period: 30s
network_mode: "host"
stop_grace_period: 10s
sysctls:
- net.core.somaxconn=65535
labels:
com.zabbix.description: "Zabbix frontend on Nginx web-server with MySQL database support"
com.zabbix.company: "Zabbix LLC"
com.zabbix.component: "zabbix-frontend"
com.zabbix.webserver: "nginx"
com.zabbix.dbtype: "mysql"
com.zabbix.os: "alpine"
secrets:
MYSQL_USER:
file: ./.MYSQL_USER
MYSQL_PASSWORD:
file: ./.MYSQL_PASSWORD
Upvotes: 1