發送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 |
無法初始化數據庫,出現錯誤無法連接到 `host=user_db user=gorm
慕工程0101907
2022-07-11 16:58:29