Suppose you have such ssh config:
Host folan_server
Port 22
User root
ForwardAgent yes
ProxyCommand ssh -A -p 22 aaa@x.x.x.x -W y.y.y.y:22
You should do this on your terminal:
ssh -N -L 5959:127.0.0.1:3306 folan_server
On your GUI that you want to see the remote database (e.g. database in Intellij products):
Host: 127.0.0.1
Port: 5959
User: {{Remote Database User}}
Password: {{Remote Database Password}}
Database: {{Remote Database Name}}
Then connect to the database as usual.
On the docker-compose file of the APP you want to connect to the database, there must be something like this:
extra_hosts:
- 'host.docker.internal:host-gateway'
Then on the .env file of your project, you should have this:
DB_USER='{{Remote Database User}}'
DB_PW='{{Remote Database Password}}'
DB_HOST='host.docker.internal'
DB_NAME='{{Remote Database Name}}'
DB_PORT='5959'