Docker Community Forums

Share and learn in the Docker community.

Connection from client to remote MySql container with tunnel

Sorry for this question but i would like find the solution.

I have a linux ubuntu server on remote machine with public ip 100.200.300.400.
In this remote machine i have a docker with MySql container with name “mysql_container” with port expose 3306:3306 and listen on 0.0.0.0 and user with % host.
In my windows database client i have this configuration:
host 100.200.300.400
port 3306
user
password
I can connect without problem.

But this is not good for security (connection with public ip) and i would like set my container for connection with 127.0.0.1 and tunneling.

I my windows database client i have this configuration:
host 127.0.0.1
port 3306
user
password

Tunnel with dbeaver:
ssh host 100.200.300.400
local host empty
local port 3306
remote host 127.0.0.1
remote port 3306

No connection.

Tunnel with putty:
ssh host 100.200.300.400
L 3306 127.0.0.1:3306

No connection.

Please can you help me? Thank you

Before connecting to MySQL from another computer, the connecting computer must be enabled as an Access Host.
Log into cPanel and click the Remote MySQL icon, under Databases.
Type in the connecting IP address, and click the Add Host button. …
Click Add, and you should now be able to connect remotely to your database.

Sorry but i don’t understand your reply.

I have connection with mySql database on my external private server.
I don’t use “cPanel”.

I would like remove public ip connection and i would like use private ip connection with tunneling.

Thank you.


Update

I can connect with tunneling on my server and with local ip with mysql container.
The problem is on sshd_conf setting used follow for fix the problem:
AllowTcpForwarding yes
PermitTunnel yes

Regards