I have a VPS with docker installed running a game server.. I have a problem: I can't connect to MariaDB 10.5.5 running on the same machine (out of docker container) with address bound to 127.0.0.1
but if I bind the address to 0.0.0.0
I can connect but HikariCP or any other mysql connector took 3000ms
to connect.. Does to solve this issue?
Asked
Active
Viewed 535 times
3

Fede1132
- 31
- 3
-
https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach – spike 王建 Aug 27 '20 at 13:34
-
the page i pasted maybe help.When you bind address to 0.0.0.0,your docker will access mysql via public network, so it is lag. – spike 王建 Aug 27 '20 at 13:36
1 Answers
0
3 second lag sounds like a DNS timeout. Add skip_name_resolve=1
to your my.cnf's [mysqld]
section.

Gordan Bobić
- 1,748
- 13
- 16
-
Not solved It yet. I tried connecting from docker container to docker container and tooks 4000ms using docker0 – Fede1132 Sep 02 '20 at 06:45
-
Are your GRANTs by hostname or IP? Are you specifying the target by hostname or IP? What DNS server is specified on each of the containers? Make sure everything uses IP addresses instead of hostnames. Can you telnet to target on port 3306? How long before you get response with server protocol version? – Gordan Bobić Sep 02 '20 at 06:55