Reputation: 303
I run two containers on EC2 instance:
docker run -d --name=grafana -p 3000:3000 grafana/grafana
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
In the Grafana dashboard when I added the host 18.211.211.211:3306
and press test, I got the following error: dial tcp 18.211.211.211:3306: connect: connection refused
Also ran the following commands, without success:
sudo firewall-cmd --permanent --zone=public --add-port=3306/tcp
sudo firewall-cmd --reload
How to solve this, any idea? Thank you
Upvotes: 1
Views: 2819
Reputation: 290
I got the solution with 2 steps.
docker run --name some-mysql -p 443:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d --rm mysql:5.7
Upvotes: 2
Reputation: 23
You have to forward the mysql port 3306 with -p 3306:3306
. For security reasons and since you are running Grafana on the same host as MySql, I'd suggest you use docker's bridge network and a private IP instead. Unfortunately the -p
option will alter your Iptables in a way that it bypasses your firewall config. You should have a look at this guide or the official docker iptable docs.
Upvotes: 1