Below is my docker-compose.yml file
version: '3.2'
services:
mysql-server:
container_name: mysql
ports:
- "13306:3306"
environment:
MYSQL_ROOT_PASSWORD: 12345
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress_user
MYSQL_PASSWORD: secret
image: mysql/mysql-server
grafana:
image: grafana/grafana
container_name: grafana
environment:
DB_HOST: mysql-server:3306
ports:
- "3000:3000"
depends_on:
- mysql-server
I would like to connect to grafana and use mysql to be my datasource. However, when I connect to grafana using 'container ip address + port' 172.19.0.3 (retrieved by using 'docker inspect containerID'):3306. It cannot connect to grafana. I tried to close my firewall but still failed. Or my method of connection is wrong?
Besides, when I set MySQL as datasource in grafana, is the host be: mysql-server:3306?
So far you have not cared about networking of the two containers. Yes, both of them expose a port on the host - but you are not trying to access that one. Instead you are trying to make a connection from one container directly to the other container.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.