1
I’m trying to raise Zabbix on Docker, I created a Docker-Compose with several services, one of them is the database. I need to survey the database first and then take the IP of the database and set in the environment variable of other services, but I do not know how to do, I have tried to use the links, but I am not succeeding.
This is my Docker-Compose.yml
version: "2"
services:
mysql-zabbix :
image: "mysql:5.7"
ports:
- "53306:3306"
networks:
- net_zabbix
volumes:
- "vol_db_zabbix:/var/lib/mysql"
environment:
- "MYSQL_ROOT_PASSWORD=abcd"
- "MYSQL_DATABASE=zabbix"
- "MYSQL_USER=zabbix"
- "MYSQL_PASSWORD=123456"
zabbix-server:
image: "zabbix/zabbix-server-mysql:alpine-3.4.11"
ports:
- "10051:10051"
networks:
- net_zabbix
environment:
- "DB_SERVER_PORT=53306"
- DB_SERVER_HOST=zabbix.db
- "MYSQL_USER=zabbix"
- "MYSQL_PASSWORD=123456"
depends_on:
- mysql-zabbix
external_links:
- mysql-zabbix:zabbix.db
zabbix-web:
image: "zabbix/zabbix-web-apache-mysql:alpine-3.4.11"
ports:
- "80:80"
networks:
- net_zabbix
environment:
- DB_SERVER_HOST=zabbix.db
- "DB_SERVER_PORT=53306"
- "MYSQL_USER=zabbix"
- "MYSQL_PASSWORD=123456"
- ZBX_SERVER_HOST=zabbix.server
- "PHP_TZ=America/Sao_Paulo"
depends_on:
- zabbix-server
external_links:
- mysql-zabbix:zabbix.db
- zabbix-server:zabbix.server
zabbix-agent:
image: "zabbix/zabbix-agent:alpine-3.4.11"
ports:
- "10050:10050"
networks:
- net_zabbix
environment:
- "ZBX_HOSTNAME=demo_zabbix"
- ZBX_SERVER_HOST=zabbix.server
external_links:
- zabbix-server:zabbix.server
zabbix-proxy:
image: "zabbix/zabbix-proxy-sqlite3:alpine-3.4.11"
ports:
- "10053:10050"
networks:
- net_zabbix
environment:
- "ZBX_HOSTNAME=demo_zabbix"
- ZBX_SERVER_HOST=zabbix.server
external_links:
- zabbix-server:zabbix.server
networks:
net_zabbix:
volumes:
vol_db_zabbix: