Connection to a containerized MySQL installation

Hi team,

I have an ubuntu server with a MySQL installation that i want to admin with Nocodb. This Nocodb installation is on another docker container, but when I try to access the MySQL db from Nocodb, is throwing Error timed out. I have exposed the port from the container and in the firewall port 3306 its open, is there any further steps that I’m missing?

I assume this is more of docker networking related question than nocodb. there are two ways to achieve this, confirm which path have you taken

  1. docker network : create docker network and launch both instances in that network, then both containers can interact by their container names directly
  2. connect via host network : your mysql db should have a port mapping (expose instruction in DockerFile wont be enough). You should pass an extra argument in docker run command of mysql —add-host=host.docker.internal:host-gateway so you can access the port mapped container through your hosts ip address.

hope this helps.

1 Like

Thanks so much for your help, it worked, I created a new docker network and connected both containers there.

Hey, I’m in the very same situation. Does this mean that nocodb connects to mysql via the javascript in the browser? (this would be very ugly x1000)

What I want is that the browser client connects only to the nocodb docker server making REST requests and then the nocodb container connects (via docker network) to the mysql container.

So the MySQL is never exposed to the public.

In my particular case I have an agency with multiple agents, I want to run all my servers in dockers and make each agent to access the data via nocodb but I DO NOT want my MySQL exposed.

Is the nocodb html rendering sending the requests to the nocodb server only? (good and nice) or is it sending the requests from the browser to the mysql? (ugly)

If it’s ugly, why this design decission? Is there anything in the roadmap to fix this?

If it’s nice, why do I need the --add-host in the MySql if it shold never be exposed?

Hey @xmontero - the original question or thread has nothing do with your doubt. So first up, avoid cross posting questions like this in old threads.

And of course, MySQL is connected or any other DB is connected from server side and NOT from browser side.

Hey, sorry, I read too fast. I thought you were suggesting to add the —add-host=host.docker.internal:host-gateway thing while you were asking the original poster if they took one path or the other.

All good, then. Understood and thanks.