Question

How do I set up SSH tunnel from inside docker image droplet to access another droplet's MySQL Database?

I have a droplet with a docker image hosting Appsmith - a low-code development platform. I want to set up an Appsmith datasource to a MySQL instance on another droplet that is not in the client droplet’s network. I’m not real good at Linux so I definitely need some guidance. I can connect to the server via SSH tunnel from my laptop.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
March 27, 2024

Heya,

You should be able to do that using a similar approach as to how you would go about when trying to configure access to another MySQL Droplet even when it’s not being inside a docker container.

By default, MySQL is configured to listen for connections only from the local machine. You need to change this so that it can accept connections from your Appsmith droplet.

Also if you do not have a user, create one. Create a user (or use an existing one) and grant privileges. Replace appsmith_user, password, and appsmith_droplet_ip with appropriate values:

CREATE USER 'appsmith_user'@'appsmith_droplet_ip' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'appsmith_user'@'appsmith_droplet_ip'; FLUSH PRIVILEGES;

If either of your droplets has a firewall enabled, you’ll need to configure it to allow the necessary traffic:

  1. MySQL Server Droplet:

    • Allow incoming connections on port 3306 (MySQL’s default port) from the Appsmith droplet’s IP address.

    • Using ufw (Uncomplicated Firewall) as an example:

      bashCopy code sudo ufw allow from appsmith_droplet_ip to any port 3306

  2. Appsmith Droplet:

    • Usually, outgoing connections are allowed, but if you have set up strict outbound rules, ensure that the droplet can make outbound requests to the MySQL server droplet on port 3306.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel