Chaibi Alaa
Chaibi Alaa

Reputation: 1386

Docker Container fails to connect to remote SQL

I am trying to run laravel project which connects to a remote SQL server of the company of a client, and all I have from laravel as a stacktrace is :

"code": 20013,
"message": "SQLSTATE[HY000] Unknown host machine name (severity 2) (SQL: get_member_head :id)",
"file": "/share/vendor/laravel/framework/src/Illuminate/Database/Connection.php",
"line": 770,

I tried changing the IP of the docker bridge, running under their vpn and outside it, nothing works. The is that the sql server host can be pinged outside docker, but inside (even in terminal) shows the same error saying unkown host machine !

Upvotes: 0

Views: 249

Answers (2)

Chaibi Alaa
Chaibi Alaa

Reputation: 1386

Inside the docker container :

 { printf "\nnameserver dns \nnameserver dns \n";} > /etc/resolv.conf;

As the container cannot reach the Internet, I couldn't setup a gedit, or vi or vim to edit this, and in all cases, the display won't load as we are in /bash so the printf is the only solution.

Upvotes: 0

istirbu
istirbu

Reputation: 311

Check if the /etc/resolv.conf in the container matches the host version and the DNS is valid.

Upvotes: 1

Related Questions