Mysql Rancher cannot connect

I am using the rancher/server:stable and my command looks like this.

sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher/server:stable --db-host dbHostname --db-port 3306 --db-user dbUser --db-pass dbPassword --db-name cattle

I created the database per the instructions online. I am starting rancher via the command above. I am getting the error below.

org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not connect to address=(host=dbHostname)(port=3306)(type=master) : dbHostname)

  1. If I try connecting remotely to the cattle db via the rancher host. It works just fine.

Is there a way to get additional details about why it will not connect?

I managed to fix the issue. After looking deeper in the stack trace I saw UnknownHost. Which I thought was odd, so I added the --dns=x.x.x.x to the start up and still got the same thing. Then I tried the IP and got a timeout error.

I started up a vanilla centos container and tried to ping google. I couldn’t. That explains why the host was not found and it timed out on the IP. It wasn’t getting any networking. I uninstalled docker, re-installed and started the rancher container and wallah. It all worked out.