Currently I have a MySQL DB running on the same VPS as my web server. For scalability purposes, and to allow my other apps to access the MySQL DB, I would like to move the DB to it’s own server. Ideally I would like to use CoreOS to host a MySQL docker image to also run some other small dockerized services on the same VPS.
What I’m unsure about is how to ensure secure connections between my web apps and the DB? i.e. encrypted connections. Should I:
It would also be great to use private networking (I know that this doesn’t secure the connections) to keep host to host communications free.
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.
Hello,
The method I would recommend is an SSH tunnel over to the host machine running the docker container. This is because it’s the more secure route than opening the docker port to the public. Generally I try to avoid opening MySQL to a public interface unless absolutely needed.
Using private networking isn’t an issue, so long as the droplets are in the same data center. This would provide a quicker response time than going over the public interface.
How you do this can vary based on your setup and what you plan to connect with. You will likely need to expose the port on the MySQL docker container with the added to your docker create or an EXPOSE directive if you use a docker file
Using docker run:
When adding to your dockerfile:
This will ensure the docker container is exposing the MySQL port to the host environment, making it accessible when you connect through your SSH tunnel.