title: Connecting to external MySQL DB in Docker
body: <p>I have made a REST API using Golang and it connects to MySQL DB present on MySQL Workbench installed locally, now I wish to dockerise this API but how do I connect to external DB in Docker-Compose?
  I'm new to docker, so have little idea of things.</p>
  <pre><code>func dbConnection() (db *sql.DB) {
      db, err := sql.Open(&quot;mysql&quot;, &quot;root:password@tcp(127.0.0.1:3306)/testDB&quot;)
      if err != nil {
          panic(err)
      }
      return db
  } 
  </code></pre>