-
Notifications
You must be signed in to change notification settings - Fork 115
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
Update docker-compose.md #276
Conversation
Mysql 的 yaml 配置文件中的 start_period 项修改; 以及 depends_on 的格式的修改
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @clien9025 ,感谢提交 PR!
container_name: halo | ||
restart: on-failure:3 | ||
depends_on: | ||
halodb: | ||
condition: service_healthy | ||
- halodb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里建议添加上 condition: service_healthy
。如果没有 condition 的话,Halo 可能在数据库还没有准备好就启动,会造成 Halo 容器多余一次或多次重启。
参考:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在 Docker Compose 文件的版本 3 中,condition 形式的 depends_on 是不支持的。所以应该使用数组形式来声明依赖关系,而不是使用映射(map)和条件。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
所以我改写成如下版本:
services:
halo:
image: halohub/halo:latest
container_name: halo
restart: on-failure
depends_on:
- halodb
# 其他配置...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我这边实际测试了一下,这样修改之后反而是有问题的:
这样会让 Halo 和 MySQL 同时启动,就会造成 MySQL 容器还没有 ready,Halo 也无法启动。
根据文档 docs.docker.com/compose/compose-file/05-services/#long-syntax-1,当前的配置方式才是正确的,我想知道你是遇到什么问题才进行这个修改的吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version: "3"
services:
halo:
image: halohub/halo:2.10.2
container_name: halo
restart: on-failure:3
depends_on:
- halodb
networks:
- halo_network
volumes:
- ./halo2:/root/.halo2
ports:
- "8090:8090"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8090/actuator/health/readiness"]
interval: 30s
timeout: 5s
retries: 5
command:
- --spring.r2dbc.url=r2dbc:pool:mysql://halodb:3306/halo
- --spring.r2dbc.username=root
- --spring.r2dbc.password=zdasdasdad
- --spring.sql.init.platform=mysql
- --halo.external-url=http://123.12.123.123:8090/
halodb:
image: mysql:8.1.0
container_name: halodb
restart: on-failure:3
networks:
- halo_network
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:
- "3306:3306"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "--silent"]
interval: 3s
retries: 5
environment:
- MYSQL_ROOT_PASSWORD=zdasdasdad
- MYSQL_DATABASE=halo
networks:
halo_network:
以上的yaml配置文件就是我本人的配置,我本人已经运行成功,博客也在使用中。还是我上述的观点(如下):
在 Docker Compose 文件的版本 3 中,condition 形式的 depends_on 是不支持的。所以应该使用数组形式来声明依赖关系,而不是使用映射(map)和条件。
PS:上述的数据库的密码和地址请自行配置(本人已修改)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
~# docker-compose version
docker-compose version 1.25.0, build unknown
docker-py version: 4.1.0
CPython version: 3.8.2
OpenSSL version: OpenSSL 1.1.1f 31 Mar 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docker Compose 版本过旧,不支持我们文档提供的 depends_on 写法,1.25.0 已经是 2019 年的版本了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docker Compose 版本过旧,不支持我们文档提供的 depends_on 写法,1.25.0 已经是 2019 年的版本了。
好的,谢谢,了解了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那我就关闭这个 PR 了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
@@ -117,14 +117,13 @@ import DockerArgs from "./slots/docker-args.md" | |||
|
|||
services: | |||
halo: | |||
image: halohub/halo:2.10 | |||
image: halohub/halo:2.10.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议不加上 patch 版本。主要是为了每次发布 patch 版本的时候不用频繁修改文档。
/close |
@ruibaby: Closed this PR. 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. |
Mysql 的 yaml 配置文件中的 start_period 项修改;
以及 depends_on 的格式的修改