am trying to do this from an ec2 instance, trying to connect to aws rds aurora mysql. The following command lets me connect to the rds: mysql -h cluster.cluster-c3dpvouhxmjg.us-east-1.rds.amazonaws.com --port 3306 -u root -p
I have written a golang application and containerized it using docker here: Dockerfile:
FROM artifactory.cloud.com/research/golang:1.10-alpine3.7
RUN mkdir -p /go/src/github.com/perfGo/
WORKDIR /go/src/github.com/perfGo
COPY ./ $WORKDIR
RUN apk update && apk upgrade
RUN go build
RUN chmod +x ./entrypoint.sh
RUN ls
RUN chmod +x ./perfGo
EXPOSE 3306
#I set the proxies here
ENTRYPOINT ["./entrypoint.sh"]
entrypoint.sh
#!/usr/bin/env bash
./perfGo
perf.go
package main
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
func main() {
db, err := sql.Open("mysql", "root:fdsffdsfs@tcp(cluster.cluster-c3dpvouhxmjg.us-east-1.rds.amazonaws.com:3306)/testdb")
checkErr(err)
_,dbErr := db.Exec("USE testdb")
if err != nil {
panic(dbErr)
}
// insert
_, inErr := db.Query("INSERT INTO books VALUES('tttt','dsfdsfs','fdsfasaf','55')")
defer db.Close()
// if there is an error inserting, handle it
if inErr != nil {
panic(inErr.Error())
}
}
func checkErr(err error) {
if err != nil {
panic(err)
}
}
The command I use to run the contianer is
docker run -p 3306:3306 -ti 23b3c5c510b4
The error I see is : panic: dial tcp: lookup cluster.cluster-c3dpvouhxmjg.us-east-1.rds.amazonaws.com on 8.8.4.4:53: read udp 172.17.0.2:52640->8.8.4.4:53: i/o timeout Can someone pls help me out on this. This totally works on container on my mac using mysql on localhost