0

I need to upload the application container and mysql server on the same host, but the containers can not find mysql server, can you help me?

DOCKER COMPOSE
version: '3'
services:
  proxy: 
    image: nginx
    ports:
     - "80:80"
     - "443:443"
    volumes:
     - /home/docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
     - /home/docker/nginx/ssl/:/etc/nginx/ssl/
    links: 
     - zabbix-web:zabbix-web
  zabbix-web:
    image: zabbix/zabbix-web-nginx-mysql:ubuntu-latest
    links:
     - zabbix-server:zabbix-server
     - mysql-server:mysql-server
    environment:
     - MYSQL_USER=user
     - MYSQL_PASSWORD=pass
     - ZBX_SERVER_HOST=zabbix-server
     - TZ=America/Sao_Paulo
  zabbix-server:
    image: zabbix/zabbix-server-mysql:ubuntu-latest
    links:
     - mysql-server:mysql-server
    ports:
     - "10051:10051"
    volumes:
     - /home/docker/zabbix-server/script/:/usr/lib/zabbix/alertscripts
    environment:
     - MYSQL_USER=user
     - MYSQL_PASSWORD=pass
  mysql-server:
    image: mysql/mysql-server:5.6
    volumes:
     - /home/data/mysql/:/var/lib/mysql
    environment:
     - MYSQL_ROOT_PASSWORD=pass
ERROR
#docker logs  docker_zabbix-server_1
**Deploying Zabbix server with mysql database
** Preparing the system
** Preparing Zabbix server
********************
* DB_SERVER_HOST: mysql-server
* DB_SERVER_PORT: 3306
* DB_SERVER_DBNAME: zabbix
* DB_SERVER_ZBX_USER: user
* DB_SERVER_ZBX_PASS: pass
********************
**** MySQL server is not available. Waiting 5 seconds...
**** MySQL server is not available. Waiting 5 seconds...
**** MySQL server is not available. Waiting 5 seconds...
  • 1
    Can you give a little more information: Docker version? What command you are using to run this? How many hosts? Docker Swarm involved? – Andy Shinn Mar 31 '17 at 00:55
  • `Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type` – 030 Apr 18 '17 at 09:24

1 Answers1

1

It looks like you are missing a couple environment variables.

First, in your mysql-server service, you are only specifying a MYSQL_ROOT_PASSWORD. This doesn't create the user and password combination you are using with the zabbix-web and zabbix-server services. You also need to specify MYSQL_DATABASE=zabbix, MYSQL_USER=user, and MYSQL_PASSWORD=pass.

Then, according to the Zabbix image documentation, you need to specify DB_SERVER_HOST=mysql-server so Zabbix knows how to get to the linked MySQL server. There is also MYSQL_DATABASE but it defaults to zabbix which is what we specified to create in the MySQL service so the default should work.

Andy Shinn
  • 4,131
  • 8
  • 38
  • 55