Unable to connect to database running on AWS-RDS

I’m a newb.

I have Docker toolbox installed on Windows 7

$ docker --version
Docker version 1.12.2, build bb80604

I am developing a web application that uses mysql running on AWS. When I run the web application locally, it connects to the database and works fine. When I run it in a docker container it fails to connect to the database with the message “Error opening conn - Communications link failure”.

While troubleshooting I discovered that the vpc that the database is in uses the same subnet as the default bridge 172.17.0.0/16. I created my own bridge

$ docker network create --driver=bridge --subnet=152.15.0.0/16 mybridge

And ran the container using that, but that still fails to connect with the same message. It seems to take a little longer to fail using mybridge than it does using the default bridge.

Any help would be appreciated

I fixed this by specifying the bip when creating the machine.

Can you explain more on how you fixed this, similar problem.

Hi! I have the same problem, I can access to AWS RDS from my localhost but when I run my docker-compose and try to connect to AWS RDS the next message is showed:

Warning: mysqli::__construct(): (HY000/1045): Access denied for user ‘xxxx’@‘XX.XX.XX.XX’

I’ve tried to modify the AWS configuration and docker-compose too but still fails.

I never did, I gave up. I now use cloud formation to build my server instances.

ISSUE RESOLVED IN MY CASE:
I was running a docker container locally on OSX. I was trying to connect to an AWS RDS instance from inside my container, using the following command:

mysql -h aws-rds-endpoint -P 3306 -u master-username -p

this was failing resulting in the following error:
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘aws-rds-endpoint.us-east-2.rds.amazonaws.com’ (111)

SOLUTION:
I found out that ‘Public Accessibility’ under ‘Connectivity’ for my RDS was set to ‘No’. I modified the setting to ‘Yes’, and it started working.