Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Conversation

clien9025
Copy link

@clien9025 clien9025 commented Nov 7, 2023

Mysql 的 yaml 配置文件中的 start_period 项修改;
以及 depends_on 的格式的修改

None

Mysql 的 yaml 配置文件中的 start_period 项修改;
以及 depends_on 的格式的修改
@f2c-ci-robot f2c-ci-robot bot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Nov 7, 2023
@f2c-ci-robot f2c-ci-robot bot requested review from guqing and lan-yonghui November 7, 2023 18:09
Copy link

f2c-ci-robot bot commented Nov 7, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign guqing for approval. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

vercel bot commented Nov 7, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
halo-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 7, 2023 6:15pm

Copy link
Member

@JohnNiang JohnNiang left a 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
Copy link
Member

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 容器多余一次或多次重启。

参考:

Copy link
Author

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)和条件。

Copy link
Author

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
    # 其他配置...

Copy link
Member

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,当前的配置方式才是正确的,我想知道你是遇到什么问题才进行这个修改的吗?

Copy link
Author

@clien9025 clien9025 Nov 16, 2023

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:上述的数据库的密码和地址请自行配置(本人已修改)

Copy link
Author

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

Copy link
Member

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 年的版本了。

https://github.com/docker/compose/blob/4038169d96ca176542c5265e21f4b18ee64b1dd9/compose/config/config_schema_v3.0.json#L79

Copy link
Author

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 年的版本了。

https://github.com/docker/compose/blob/4038169d96ca176542c5265e21f4b18ee64b1dd9/compose/config/config_schema_v3.0.json#L79

好的,谢谢,了解了

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那我就关闭这个 PR 了。

Copy link
Author

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议不加上 patch 版本。主要是为了每次发布 patch 版本的时候不用频繁修改文档。

@f2c-ci-robot f2c-ci-robot bot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Nov 8, 2023
@ruibaby
Copy link
Member

ruibaby commented Nov 25, 2023

/close

@f2c-ci-robot f2c-ci-robot bot closed this Nov 25, 2023
Copy link

f2c-ci-robot bot commented Nov 25, 2023

@ruibaby: Closed this PR.

In response to this:

/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants