-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
I run my mysql container by below cmd:
docker run -d -i -t --mount type=bind,src=/Users/eysirs/database/mysql,dst=/var/lib/mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql
I run my gin web container by Docker Desktop:
desc:
I can connect to MySql by Navicat and all operation is available.
But my Gin web app can not connect to MySql.
go code:
db, err := xorm.NewEngine("mysql", "root:123456@tcp(localhost:3306)/nices?charset=utf8")
if err != nil {
fmt.Println("something is wrong, err:", err.Error())
}
gin web container shows:
[GIN-debug] Listening and serving HTTP on :8080
insert person throw err: dial tcp [::1]:3306: connect: connection refused
[GIN] 2025/11/26 - 17:50:38 | 200 | 1.55525ms | 142.250.184.145 | POST "/create"
What is wrong?