<p>I'm using GCloud, I have a kubernate cluster and a cloud sql instance.</p>

<p>I have a simple node.js app, that uses database. When I deploy with <code>gcloud app deploy</code> it has an access to a database. However, when I build a dockerimage and expose it, it cannot reach database.</p>

<ol>
<li>I expose Docker application following: <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app</a></li>
<li>Cloud SQL deosn't have Private IP enabled, Im connecting using cloud sql proxy</li>
<li>In app.yaml I do specify <code>base_settings:cloud_sql_instances</code>. I use the same value in <code>socketPath</code> config for mysql connection.</li>
<li><p>The error in docker logs is:</p>

<p>(node:1) UnhandledPromiseRejectionWarning: Error: connect ENOENT /cloudsql/x-alcove-224309:europe-west1:learning
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)</p></li>
</ol>

<p>Can you please explain me how to connect to cloud sql from dockerized node application.</p>

<p>Generally, the best method is to connect using a sidecar container inside the same pod as your application. You can find examples on the "Connecting from Google Kubernetes Engine" page <a href="https://cloud.google.com/sql/docs/mysql/connect-kubernetes-engine" rel="nofollow noreferrer">here</a>. There is also a codelab <a href="https://github.com/GoogleCloudPlatform/gmemegen" rel="nofollow noreferrer">here</a> that goes more in-depth and might be helpful. </p>
