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

Become a contributor for community

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

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.