Home > database >  Docker Container cant connect to MySQL database
Docker Container cant connect to MySQL database

Time:05-14

I have a MySQL instance running in a docker container, available on my host system at port 3333. I already tested the connection via the MySQL workbench to verify, that the user I created is able to login to the SQL server.

I also have a wikijs (installation guide found here) instance running in a container. I have provided all the required environment variables, including the information of the user I already tested, but the container always says that the connection was refused.

Does anybody have an idea on what the problem is?

CodePudding user response:

No information does not help solving your problem but a wild guess:

By default docker containers are joining a virtual network separate from host named bridge.

You can't reach host by localhost or 127.0.0.1, because this is pointing to your docker container itself. To reach host directly either let container use hosts IP by --network=host (with some disadvantages) or use host.docker.internal as DNS-Name instead of an IP.

BUT you should not take the way over host, connect directly to the mySQL-container by using the alias or IP or the container. You'll get that by docker inspect <containername>. No need to map ports then..

CodePudding user response:

Kindly try adjusting the port to 3306 and see if it works

  • Related