对 docker 不是很熟悉。
按照官网的例子修改了一下 docker-compose.yml 文件,只有 postgresql 能正常启动,halo 启动失败,下面是 halo 的一部分错误信息
Caused by: org.springframework.dao.DataAccessResourceFailureException: Failed to obtain R2DBC Connection
at org.springframework.r2dbc.connection.ConnectionFactoryUtils.lambda$getConnection$0(ConnectionFactoryUtils.java:100) ~[spring-r2dbc-6.1.12.jar:6.1.12]
at reactor.core.publisher.Mono.lambda$onErrorMap$29(Mono.java:3862) ~[reactor-core-3.6.9.jar:3.6.9]
at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:94) ~[reactor-core-3.6.9.jar:3.6.9]
... 43 common frames omitted
Caused by: io.r2dbc.postgresql.PostgresqlConnectionFactory$PostgresConnectionException: Cannot connect to vps-postgresql/<unresolved>:5432
at io.r2dbc.postgresql.PostgresqlConnectionFactory.cannotConnect(PostgresqlConnectionFactory.java:188) ~[r2dbc-postgresql-1.0.5.RELEASE.jar:1.0.5.RELEASE]
at io.r2dbc.postgresql.PostgresqlConnectionFactory.lambda$doCreateConnection$7(PostgresqlConnectionFactory.java:153) ~[r2dbc-postgresql-1.0.5.RELEASE.jar:1.0.5.RELEASE]
at reactor.core.publisher.Mono.lambda$onErrorMap$29(Mono.java:3862) ~[reactor-core-3.6.9.jar:3.6.9]
at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:94) ~[reactor-core-3.6.9.jar:3.6.9]
... 27 common frames omitted
Caused by: java.net.UnknownHostException: vps-postgresql
at java.base/java.net.InetAddress$CachedLookup.get(Unknown Source) ~[na:na]
at java.base/java.net.InetAddress.getAllByName0(Unknown Source) ~[na:na]
at java.base/java.net.InetAddress.getAllByName(Unknown Source) ~[na:na]
at io.netty.util.internal.SocketUtils$9.run(SocketUtils.java:169) ~[netty-common-4.1.112.Final.jar:4.1.112.Final]
我的配置文件是
services:
halo:
image: registry.fit2cloud.com/halo/halo:2.19
container_name: vps-halo
restart: on-failure:3
depends_on:
halodb:
condition: service_healthy
network_mode: bridge
volumes:
- ./halo2:/root/.halo2
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8090/actuator/health/readiness"]
interval: 30s
timeout: 5s
retries: 5
start_period: 30s
command:
- --spring.r2dbc.url=r2dbc:pool:postgresql://vps-postgresql:5432/halo
- --spring.r2dbc.username=halo
# PostgreSQL 的密码,请保证与下方 POSTGRES_PASSWORD 的变量值一致。
- --spring.r2dbc.password=openpostgresql@password@123
- --spring.sql.init.platform=postgresql
halodb:
image: postgres:15.4
container_name: vps-postgresql
restart: on-failure:3
network_mode: bridge
volumes:
- ./db:/var/lib/postgresql/data
healthcheck:
test: [ "CMD", "pg_isready" ]
interval: 10s
timeout: 5s
retries: 5
environment:
- POSTGRES_PASSWORD=openpostgresql@password@123
- POSTGRES_USER=halo
- POSTGRES_DB=halo
- PGUSER=halo
有大佬帮忙看一下是什么问题吗?