I created grafana with a docker container. And I created mysql with docker container. After that, I tried to access grafana and add mysql container via 'data source'. However, the following error occurred. What is the problem?
db query error: query failed - please inspect Grafana server log for details
[grafana's data sources setting]
Host : 10.0.7.35:3306
And I set bind-address at '/etc/mysql/my.cnf' for 0.0.0.0:3306 in mysql container.
CodePudding user response:
You can do it in three ways
- You can run docker with MySQL and expose 3306 (by adding
-p 3306:3306
port and find IP of docker and connect to that port on that IP from the same network - Expose MySQL port and then run app docker with
--link name_of_mysql_container:mysql
and then on the app docker just connect to name_of_mysql_container - Use Docker composer create docker-composer.yml with content similar to:
version: '3.2'
services:
app:
build: .
image: lap
environment:
- DB_HOST=mysql
mysql:
image: mysql
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=root
And then you can use in your app container database connection to host named 'mysql'