01-06-2024, 09:44 AM
I'm facing an issue where I'm unable to connect to a MySQL database that is running on my host machine from a Docker container which houses Nginx. The MySQL instance is configured to listen on localhost (127.0.0.1), and I need to find a way to access it from within the container. I understand that containers are isolated environments and have their own localhost. I'm looking for some insight into a viable method or workaround for establishing a connection to the host's MySQL instance from the Docker container. Here is my current MySQL configuration:
I've considered updating the bind-address to 0.0.0.0 to allow connections from any host, but for security reasons, I want to avoid this approach. Is there a way to securely connect from my Docker container to the MySQL service running on the localhost of the host without changing the bind-address setting to 0.0.0.0?
Code:
bind - address = 127.0 .0 .1
I've considered updating the bind-address to 0.0.0.0 to allow connections from any host, but for security reasons, I want to avoid this approach. Is there a way to securely connect from my Docker container to the MySQL service running on the localhost of the host without changing the bind-address setting to 0.0.0.0?