-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在一个服务器上使用docker-compose方式搭建第二个halo,使用容器名连接数据库失败,使用容器ip可以成功 #5019
Comments
有没有可能数据库端口绑定出了问题🤣 |
docker 网络问题 |
1 similar comment
docker 网络问题 |
不过突然想起来这个和我之前那个 next.js docker 形式解析后端服务 |
检查了容器间的通信是正常的,网络是在同一个网段,可以排除是网络原因,但是halo无法使用容器名的方式通信,应该是halo的bug |
使用你的配置文件测试了一下,确实无法正常启动,但我尝试去掉 url 的 3306 端口之后就可以了,可能和 halo-dev/docs#269 (comment) 是同样的问题,目前不太清楚为什么会有这样的差异,但这和 Halo 本身应该无关。 此外,你的密码似乎设置的也不对。 最终可运行的 docker-compose.yaml: version: "3"
services:
halo_8080:
image: halohub/halo:2.11
container_name: halo_8080
restart: on-failure:3
depends_on:
halodb_8080:
condition: service_healthy
networks:
halo_network2:
volumes:
- ./halo2:/root/.halo2
ports:
- "8080:8090"
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:mysql://halodb_8080/halo
- --spring.r2dbc.username=root
# MySQL 的密码,请保证与下方 MYSQL_ROOT_PASSWORD 的变量值一致。
- --spring.r2dbc.password=@@@@@
- --spring.sql.init.platform=mysql
# 外部访问地址,请根据实际需要修改
- --halo.external-url=http://47.254.43.129:8080/
halodb_8080:
image: mysql:8.1.0
container_name: halodb_8080
restart: on-failure:3
networks:
halo_network2:
command:
- --default-authentication-plugin=caching_sha2_password
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_general_ci
- --explicit_defaults_for_timestamp=true
volumes:
- ./mysql:/var/lib/mysql
- ./mysqlBackup:/data/mysqlBackup
ports:
- "3307:3306"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
interval: 3s
retries: 5
start_period: 30s
environment:
# 请修改此密码,并对应修改上方 Halo 服务的 SPRING_R2DBC_PASSWORD 变量值
- MYSQL_ROOT_PASSWORD=@@@@@
- MYSQL_DATABASE=halo
networks:
halo_network2: |
原因参考这个: /remove-triage needs-information |
@guqing: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
系统信息
http://47.254.43.129:8080/console
使用的哪种方式运行?
Docker Compose
在线站点地址
http://47.254.43.129:8080/
发生了什么?
连接数据库使用容器名的方式,会导致数据库连接失败,使用容器ip可以成功
异常信息:Caused by: java.net.UnknownHostException: Failed to resolve 'halodb_8080:3306' [A(1)] after 2 queries
相关日志输出
附加信息
docker-compose.yml
The text was updated successfully, but these errors were encountered: