I have a simple web app running in Docker on a cloud server, consisting of an Nginx container and a MySQL container, both on the same 'webapp' network. While Nginx has ports 80 and 443 exposed, MySQL does not have any ports exposed. I'm looking for a way to connect to the MySQL database from my local machine without opening up any ports. Is it possible to access the webapp network from the outside?
3 Answers
If you have the option to SSH into your server, you can create a tunnel to access MySQL that way. Make sure you have SSH key authentication set up for security. Additionally, you might want to restrict the SSH access to your IP for added safety. Using a firewall to limit access to the MySQL port is also a good move.
One option is to set your Docker network to 'host'. This way, it can directly use the network of the host system, which simplifies access. Just check the Docker documentation for more details on the host network driver.
Since you want to keep MySQL off the public internet, it's smart that you've set it up on the internal Docker network. To connect from your local machine without opening the MySQL port to everyone, you can bind MySQL to localhost on the server and create an SSH tunnel. It's a safe way to access your database without exposing it.

Related Questions
How to Build a Custom GPT Journalist That Posts Directly to WordPress
Cloudflare Origin SSL Certificate Setup Guide
How To Effectively Monetize A Site With Ads