亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法初始化數據庫,出現錯誤無法連接到 `host=user_db user=gorm

無法初始化數據庫,出現錯誤無法連接到 `host=user_db user=gorm

Go
慕工程0101907 2022-07-11 16:58:29
發送gorm.io/gorm v1.20.6gorm.io/driver/postgres v1.0.錯誤文本user_1     | [error] failed to initialize database, got error failed to connect to `host=user_db user=gorm database=gorm`: dial error (dial tcp 172.18.0.2:9920: connect: connection refused)user_1     | panic: failed to connect to `host=user_db user=gorm database=gorm`: dial error (dial tcp 172.18.0.2:9920: connect: connection refused)所有日志$ docker-compose upStarting urlshortener_user_db_1 ... doneStarting urlshortener_user_1    ... doneStarting urlshortener_gateway_1 ... doneAttaching to urlshortener_user_db_1, urlshortener_user_1, urlshortener_gateway_1user_db_1  | user_db_1  | PostgreSQL Database directory appears to contain a database; Skipping initializationuser_db_1  | user_db_1  | 2020-11-13 04:21:54.059 UTC [1] LOG:  starting PostgreSQL 13.0 on x86_64-pc-linux-musl, compiled by gcc (Alpine 9.3.0) 9.3.0, 64-bituser_db_1  | 2020-11-13 04:21:54.059 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432user_db_1  | 2020-11-13 04:21:54.059 UTC [1] LOG:  listening on IPv6 address "::", port 5432user_db_1  | 2020-11-13 04:21:54.070 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"gateway_1  | [GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.gateway_1  | gateway_1  | [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.gateway_1  |  - using env:      export GIN_MODE=releasegateway_1  |  - using code:     gin.SetMode(gin.ReleaseMode)gateway_1  | 
查看完整描述

1 回答

?
慕無忌1623718

TA貢獻1744條經驗 獲得超4個贊

因為圖像postgres:alpine是被暴露的端口5432

嘗試將連接字符串中的端口 更改- 9920:9920- 5432:5432port=5432


查看完整回答
反對 回復 2022-07-11
  • 1 回答
  • 0 關注
  • 123 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號